Page 1 of 1

USB-to-Serial Problem OSX

Posted: Sun Jan 16, 2011 5:42 pm
by xfratboy
I have a device (motor with serial interface) sitting behind a usb-to-serial adapter (FTDI FT232R chipset). The motor requires 19,200, 8N1 serial settings. I can turn motor on and off perfectly in Win32 platform but everything falls apart under OSX. The motor intermittently turns on (sometimes it works, sometimes it doesn't). I think it must have something to do with setting the Baud rate or the FTDI VCP driver for OSX. Any ideas or input? Maybe someone out there has worked on something like this before and has the magic answer.


Here's the code I use:

Code: Select all

on MouseUp  -- Turn On Motor Button
set the serialControlString to "BAUD=19200 PARITY=N DATA=8 STOP=1"
if the platform = "MacOS" then
         open driver (the ComPortName of this Stack) for write  
         write (the MotorOnCommand of this Stack) to driver (the ComPortName of this Stack)
         close driver (the ComPortName of this Stack) 
      Else 
          open file(the ComPortName of this Stack) for write 
         write (the MotorOnCommand of this Stack) to file (the ComPortName of this Stack)
         close file (the ComPortName of this Stack) 
end if
End MouseUp

Re: USB-to-Serial Problem OSX

Posted: Mon Jan 17, 2011 12:25 am
by bn
Hi Xfratboy,

I don't know anything about USB etc. But on the Livecode-list the other day a similar problem was discussed.

http://runtime-revolution.278305.n4.nab ... l#a3219705

quote from Jaqce
This came up in the support queue. Basically "open driver" is only for
(real) serial devices. To open a usb device that is posing as a serial
device (i.e., you have a usb/serial port adapter) then you should use
"open file" instead. Treat the port just as you would a regular file.

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.
Seems that you should address the usb-serial port as file. It might pertain to your problem since I see you do an open driver when on the mac.

As I said, I never did this kind of stuff.

Kind regards

Bernd

Re: USB-to-Serial Problem OSX

Posted: Mon Jan 17, 2011 3:18 am
by xfratboy
Thanks for the reply Bernd. WRITE TO FILE method doesn't work at all. I can only get partial functionality by using the WRITE TO DRIVER method. Since the virtual port is recognized by the DRIVERNAMES method it would seem logical that the WRITE TO FILE method should work...but it doesn't. Maybe someone else will run across this thread and enlighten me.