USB HxC: Raspberry Pi Lost Sync

General discussion forum - for all that doesn't fit in any other category.
Post Reply
cjwalters
Posts: 5
Joined: Tue Sep 10, 2013 12:19 am

USB HxC: Raspberry Pi Lost Sync

Post by cjwalters »

I'm attempting to use a raspberry Pi to host some files to an old MSDOS based cnc machine. I've gotten the software to compile successfully and run. I'm using Raspbian Linux raspberrypi 3.6.11.

At first I couldn't get communication to work at all until I increase my usb packet size. Running at the max of 4096 I get a steady stream of data being send in the usb diagnostics page. The sync lost counter still ticks now and then. When I start to load files off the disk it only works intermittently and I get some errors here and there reading files.

I've tried both USB 2.0 and USB1.1 modes and I get the same issue.
@4096 packet size
Max settle time=32ms
Min settle time=16ms

How can I fix these lost syncs and get it to work reliably?

Any further idea would be greatly appreciated.
--chris

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »

Interesting. I just got an RasberryPi, and the USB version doesn't work yet here. So you are more advanced than me for the moment :wink:
i have to test is to see how the thing should be optimized.

Note : have you tried to increase the HxC process priority ?
Also : i recommend you to use/try the command line version.

cjwalters
Posts: 5
Joined: Tue Sep 10, 2013 12:19 am

Re: USB HxC: Raspberry Pi Lost Sync

Post by cjwalters »

I've tried increasing the priority via the nice command. It didn't help. I tried the command line version first but it uses 100% cpu all the time and still barely works. I would prefer the command line version. The gui version doesn't seem to have this issue. Based on some testing with gdb, hxcfe seems to be continually polling libftdi. I'm using the latest trunk version.

I also discovered that the libftdi on ftdi.com's page does not function correctly on my version. After some digging I found an alternate version not generally released by FTDI that does work. http://download1921.mediafire.com/itqn9 ... ftd2xx.zip

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »

i think that i need to switch (again) to the open source version of the ftdi driver :
http://developer.intra2net.com/git/?p=libftdi;a=summary
this was already done long time ago.

The thing worked on something a lot less powerfull than a raspberry Pi :
https://hxc2001.com/floppy_drive_emulat ... dusb_9.jpg

cjwalters
Posts: 5
Joined: Tue Sep 10, 2013 12:19 am

Re: USB HxC: Raspberry Pi Lost Sync

Post by cjwalters »

Is that a simple change? Can I just relink the code using that library instead? This I can probably manage as long as I don't have to rewrite alot of code.

My understanding is that ftdi devices are just usb serial converters. Doesn't that mean the serial port can be opened directly and used, eg. /dev/ttyUSBx or COMx. If so then there would be no need for either libftdi.

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »

cjwalters wrote:Is that a simple change? Can I just relink the code using that library instead? This I can probably manage as long as I don't have to rewrite alot of code.

My understanding is that ftdi devices are just usb serial converters. Doesn't that mean the serial port can be opened directly and used, eg. /dev/ttyUSBx or COMx. If so then there would be no need for either libftdi.
i will work on this ASAP since i want to test/evaluate these kind of solutions for our next emulator (an high-end solution :wink: )

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »

Done ! LibFTDI support added, thread priority setting corrected!
Just do an apt-get to get the libFTDI.
The thing is now working well ! i will make a video ! :D
(Note : For HD disks, the USB buffer need to be set at 4096)

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »





:wink:

cjwalters
Posts: 5
Joined: Tue Sep 10, 2013 12:19 am

Re: USB HxC: Raspberry Pi Lost Sync

Post by cjwalters »

Thanks! So far it's working well. I'll finish up testing and let you know if I find any other troubles.

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »

cjwalters wrote:Thanks! So far it's working well. I'll finish up testing and let you know if I find any other troubles.
Also interested by details of your application. Don't hesitate to share some pictures of your machine and the emulator.

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »

Update -> control & upload through a simple web browser :D


cjwalters
Posts: 5
Joined: Tue Sep 10, 2013 12:19 am

Re: USB HxC: Raspberry Pi Lost Sync

Post by cjwalters »

The goal of my project is to save the work of walking out to the shop with a floppy for each job. To this end I configured the raspberry pi with a Samba share. This will let the user dump their files to the share. A cron job is setup to run every minute. It detects if a change has been made to the files on the share, if so it will recreate the floppy image and then kill and restart hxcfloppyemulator so that the new image is available to the dos machine.

I had to modify the hxcfloppyemulator to autoload an image on start. The command line hxcfe would probably work too, but I wanted the user to be able to connect in via VNC to debug issues via the GUI.

Copy script follows. I would prefer to attach it, but the forum won't allow .sh or .conf files to be attached.

#!/bin/bash
cd /root/cnc

touch md5old
cat data/* | md5sum >md5new
diff md5new md5old

if [ $? == 0 ]
then
echo "no changes1"
elif [ $? == 1 ]
then
echo "changes found"
#start with empty image
#cp empty.hfe disk.hfe
mformat -C -f 1440 -v WINVBLOCK -i disk.img ::
cd data
mcopy -n -i ../disk.img * ::
#for f in *
#do
# echo "Adding file $f";
# hxcfe -finput:../disk.hfe -putfile:$f
#done
cd ..
killall hxcfloppyemulator
export DISPLAY=:1
hxcfloppyemulator&
# hxcfe -finput:disk.img -usb:1
mv md5new md5old
else
echo "There was something wrong with the diff command"
fi

Jeff
Site Admin
Posts: 8092
Joined: Fri Oct 20, 2006 12:12 am
Location: Paris
Contact:

Re: USB HxC: Raspberry Pi Lost Sync

Post by Jeff »

Interesting ! Which CNC machine it is ?

Post Reply