usb driver problem

Ben Rubinstein benr_mc at cogapp.com
Fri Jan 21 05:32:24 EST 2011


Tom,

Caveats: I've not tried connecting to an Arduino, and I've done almost nothing 
with serial generally... so I don't really know what I'm talk about.  But, 
when I was working with GPS (which are USB with FTDI etc pretending to be 
serial) I found two things:

a) I know this is obvious, but it really matters that you get the serial 
parameters right - getting the right speed is only part of it, if you get the 
rest wrong you may get it seeming to work but it will be unreliable.  I've no 
reason to think you haven't done this, I just thought it was worth mentioning.

b) More usefully perhaps, the code you quote below is reading from the port 
until (rec)eol; I would expect that this may be where it's hanging (and 
displaying the spinning pizza).  The GPS unit was also supposed to speak to in 
complete lines, but I found that rather than rely on this, I did better by 
having a regularly scheduled task that read whatever was available on the 
serial line, and added it to an internal buffer.  Any time new data was read, 
it then called another function to take all complete lines out of the buffer 
and process them.  This was using read from driver instead of read from file, 
as the former allows you to issue a read command which returns either when a 
certain quantity of date has been read (I settled on 10 lines at a time) or a 
time limit has been exceeded.  I'm not sure if you have the option to read 
from driver instead of file, or whether you can use a similar mode with read 
from file; but at any rate, I'd expect your spinning pizza might occur when 
read from file is waiting for EOL.

HTH,

Ben


On 21/01/2011 06:19, Thomas McGrath III wrote:
> Actually, as long as data is coming from the Arduino the app works. The data comes in and fills the field. But after the data stops being sent the system hangs. Until I push the button on the Arduino to send more data in which case the beach ball goes away and the new data gets received again.
>
> It's like as long as data keeps everything is fine. I can even close the port in the middle of getting data but If it gets to the end of the current stream the system hangs and I can't even close the port. I put code in to close the port after data stops and that is working I think but the system still hangs like it's waiting for more.
>
>
> -- Tom McGrath III
> http://lazyriver.on-rev.com
> 3mcgrath at comcast.net
>
> On Jan 21, 2011, at 1:12 AM, Thomas McGrath III wrote:
>
>> OK well I can read the data from the USB Serial Modem -- but -- after it is done the app hangs.
>>
>> So I can open the port and then read the port and I think close the port but the system hangs.
>>
>> HELP.... ??
>> -- Tom McGrath III
>> http://lazyriver.on-rev.com
>> 3mcgrath at comcast.net
>>
>> On Jan 21, 2011, at 12:48 AM, Thomas McGrath III wrote:
>>
>>> It seems if I set the EOL to CRLF things work partly. i.e. The numbers show up in the field BUT the script keeps looping and will not stop causing the beach ball.
>>>
>>> Sarah's code:
>>> on readPort
>>> if the hilite of btn "Port open" = true then
>>>
>>>    if recEOL is "empty" then resetEOL
>>>
>>>    put the label of btn "Port" into thePort
>>>    if the hilite of btn "OS X" then
>>>      read from file thePort until recEOL
>>>    else
>>>      read from file thePort until recEOL
>>>    end if
>>>    if it is not empty then put it after fld "recField"
>>>    if last char of fld "recField"<>  cr then put cr after fld "recField"
>>>    send readPort to me in 5 ticks
>>> end if
>>> end readPort
>>>
>>>
>>>
>>> -- Tom McGrath III
>>> http://lazyriver.on-rev.com
>>> 3mcgrath at comcast.net
>>>
>>> On Jan 21, 2011, at 12:05 AM, Thomas McGrath III wrote:
>>>
>>>> UPDATE: Something is working but makes no sense.
>>>>
>>>> Found a few terminal screen ideas but they are outside of Livecode. No good.
>>>> Found a few applescript examples but would rather keep this crossplatform if possible and a LC to OSC solution would work on iOS but applescript would not. Not best but may have to go this route.
>>>>
>>>> Found a few softwares that access the USB modem (not FTDI serial emulation) as serial which leads me to believe LC can still do this even with the change from software emulation of a serial port to the hardware emulation of a serial port. So I looked again at Sarah's serialTest stack.
>>>>
>>>> I had to manually add the /dev/tty.usbmodem1a21 and /dev/cu.usbmodem1a21 to the popup menu. Then find replace driver with file in five places in the stack. Now most of the other solutions use the tty but two use the cu so I tested both. Major hang and LC not responding in Force Quit Window.
>>>>
>>>> Command period no good.
>>>> Esc no good.
>>>> Force quit. quits but no good and driver may still be open.
>>>>
>>>> Unplug Arduino Uno and plug it back in. HUH Serial Input Shows Up In Field !!!!!! Beach ball of almost death goes away. Also port is now closed I think. Also Arduino Tx led not lighting anymore - should be though. Wait replug Arduino rest button on Arduino and serial Tx led is working again. But no longer connected to LC. Try again. Open cu port and beach ball of almost death shows up - LC not responding in Force Quit Window - Unplug Arduino and field fills up with serial data. THe data is a bunch of 1 and 0 based on blinking led.
>>>>
>>>> SO this seems to say it is connecting but not communicating well. Not knowing enough about serial commands I am not sure what is causing the hang and not responding??? They are both set to 9600. I read somewhere that the trailing bit is or should be ignored.
>>>>
>>>> Is there another way to connect via message box with out clutter from other settings ? Any ideas on what the culprit is here?
>>>>
>>>> Thanks for staying with me on this one.
>>>>
>>>>
>>>> -- Tom McGrath III
>>>> http://lazyriver.on-rev.com
>>>> 3mcgrath at comcast.net
>>>>
>>>> On Jan 15, 2011, at 10:37 PM, Mark Wieder wrote:
>>>>
>>>>> Jacque-
>>>>>
>>>>> Saturday, January 15, 2011, 7:31:30 PM, you wrote:
>>>>>
>>>>>> There's no USB support per se, so if the device doesn't present itself
>>>>>> as a serial port device it won't work.
>>>>>
>>>>>> The path you use when you open a serial port as a file is the same one
>>>>>> you'd use in shell -- use the "/dev/tty.usbmodem1a21" path you
>>>>>> mentioned. Also, see if you can talk to it in shell just as a test.
>>>>>
>>>>> That should work then, since the Arduino driver has always presented
>>>>> itself as a serial port.
>>>>>
>>>>> --
>>>>> -Mark Wieder
>>>>> mwieder at ahsoftware.net




More information about the use-livecode mailing list