SD84 - Need help with MacOSX

Motor, Servo, Speech etc.

Moderator: chris

SD84 - Need help with MacOSX

Postby SKoT » Sat Jul 19, 2008 10:53 am

Hi,

The Windows Visual Studio example for the SD84 was a great head start into the world of SD84 programming. I am trying to also build a MacOSX equivalent (will be happy to share an xcode project with everyone).

I have downloaded the Mac drivers from FTDI, and when I plugin the SD84, I see a new USB device in /dev/ with the correct name. I am then following Apple's COM port coding manual to talk to the SD84, setting all the parity / end bits / baud rate to match the COM port initialization settings in the windows example project code. I have been able to apparently open and initialize the SD84's port, but when I attempt a write on the port, it fails (0 bytes written). The bytes I am writing are those for the "get version" command, which I was going to use as a basic test for the SD84's connection on that port. This is on Leopard 10.5.4.

Has anyone managed to get a Mac talking to an SD84, and are they willing to share the basic SD84 port initialization and communications code?

- SKoT
SKoT McDonald | FXpansion Audio UK Ltd | http://www.fxpansion.com
SKoT
 
Posts: 3
Joined: Sat Jul 19, 2008 10:28 am

Re: SD84 - Need help with MacOSX

Postby Greg » Thu Aug 27, 2009 5:00 pm

Dear Skot,

I also am trying to develop a program for the Mac,
please let me know if you've made any progress.
I'd be glad for any example codes.
Sorry I cannot help (yet!)

Greg
Greg
 
Posts: 2
Joined: Thu Aug 27, 2009 4:57 pm

Re: SD84 - Need help with MacOSX

Postby jonesboy » Sat Oct 03, 2009 7:53 pm

Hey guys-

I'm actually building a generic libsd84 (for Darwin / Linux / etc.) in C++ right now for a personal project - I'm planning to open-source it once I'm done, but here's an earlier (dirt-simple) C version of the serial port communication code which I know to be good:

Code: Select all
int sd84_startCommunications(const char *path) {
        int device;
        struct termios options;

        device = open(path, O_RDWR | O_NOCTTY | O_NONBLOCK);
        if (device != -1) {
                ioctl(device, TIOCEXCL);
                fcntl(device, F_SETFL, 0);
                tcgetattr(device, &options);
                cfmakeraw(&options);
                options.c_cc[VMIN] = 1;
                options.c_cc[VTIME] = 10;
                cfsetspeed(&options, B115200);
                tcsetattr(device, TCSANOW, &options);
        }
        else {
                printf("Error opening serial port %s - %s(%d).\n", path, strerror(errno), errno);
        }
        return device;
}

void sd84_endCommunications (int device) {

        close(device);
}

int sd84_sendCommand(int device, long len, unsigned char *command, long respLen, unsigned char *response) {
        long i = 0;
        int ret;

        if (device &&
                command &&
                len > 0) {

                sd84_dumpCommand(len, command);
                ret = write(device, command, len);
                if (ret != len) {
                        return -1;
                }

                snprintf((char *)response, respLen, "\0");
                fcntl(device, F_SETFL, 0);
                ret = read(device, response, respLen);
                fprintf(stderr, "DEBUG: read() says we received %i bytes from device\n", ret);

                return len;
        }
        return -1;
}


Make sure to use the "cu.usbserial-A2001xxx" version of the handle in /dev/; the other one is used for "inbound calls" (i.e. OS X expects it to be a modem and that handle would be where an inbound RING from a Hayes-style serial modem would come it to a listening application).

I'll post up the C++ library code once it's complete, but hope this helps you for now.

-Matt
jonesboy
 
Posts: 2
Joined: Sat Oct 03, 2009 7:47 pm

Re: SD84 - Need help with MacOSX

Postby jonesboy » Sat Nov 07, 2009 2:53 am

As promised, the library code is available from SourceForge now. Definitely not yet bug-free, and not even close to 100% tested. Servo outputs work. Analog inputs don't and they're driving me up the bloody wall - post coming soon about that issue.

http://libsd84.svn.sourceforge.net/viewvc/libsd84/

This is all being developed under OS X and Ubuntu Linux simultaneously - the single-board computer my robot will be running off of is Linux and my notebook is OS X.

-Matt
jonesboy
 
Posts: 2
Joined: Sat Oct 03, 2009 7:47 pm


Return to Drivers

Who is online

Users browsing this forum: No registered users and 1 guest