JoeJ
Posts: 1435
Joined: Sun Feb 16, 2014 10:52 am

Instructions for adding 250k baud rate support in OS X

Sat Mar 22, 2014 7:49 am

As many of your know, the Simplify3D software can have difficulty connecting to devices at the 250000 baud rate in OS X. After some research on the topic, I think I figured out what would be required to add support for this non-standard baud rate on the Mac. I came across this document which explains how the driver settings for FTDI devices are maintained in OS X.

http://www.ftdichip.com/Support/Documen ... Driver.pdf

Basically, each hardware device gets a unique Vendor ID (VID) and Product ID (PID). When you connect a USB device, the system looks through the /System/Library/Extensions/FTDIUSBSerialDriver.kext/Contents/Info.plist file to locate the correct settings to use based on the VID/PID combination. For example, plug in your 3D printer and go to About This Mac > More Info. Click USB on the list to the left and you can locate the VID and PID for your device (see screenshot).
SystemInfo.png
Now, in my case, this VID/PID pair is not present in my Info.plist file (note that you have to convert the hex characters to decimal first). In that case, I'm not 100% sure what settings are used. Maybe there is a default fallback entry somewhere, but I have a feeling that all we need to do is add a custom dictionary entry into this file and that will allow us to change the baud rate settings for our 3D printers.

On page 6 of the PDF I linked to, it says "the standard baud rates are as follows: B300, B600, B1200, B2400, B4800, B9600, B19200, B38400, B57600, B115200 and B230400". And as you probably noticed, the 250000 baud rate is not on that list! Fortunately for us, the FTDI drivers allow for something called baud rate aliasing. This means that we can essentially replace one of those rarely used standard baud rates with a custom rate that we define. For example,

Code: Select all

<key>BaudRates</key>
<dict>
    <key>B300</key>
    <integer>250000</integer>
</dict>
This would replace the 300 bps rate with 250000. So if the Simplify3D software tried to connect to the device at 300 bps, it would actually use 250000! This way we could replace any entry we want with the non-standard 250k rate.

After reading this document, things make a lot more sense to me. My particular 3D printer did not have an entry in the Info.plist file, so how could the program use any baud rate other than the standard rates I listed earlier? But most importantly, I think the fix for this is fairly easy. Edit the Info.plist file to include a VID/PID entry for your 3D printer and then use baud rate aliasing to allow for any non-standard rates that you want. After you make the change, you would need to unplug your USB device and run the following commands:

sudo kextunload -b com.FTDI.driver.FTDIUSBSerialDriver
sudo kextload -b com.FTDI.driver.FTDIUSBSerialDriver

That will reload the newly modified driver settings.

Has anyone else tried this before? Do you see any problems with this idea?

Edit: Here's another useful link that I found:
http://spin.atomicobject.com/2013/06/23 ... river-mac/

jsc
Posts: 39
Joined: Wed Mar 12, 2014 2:21 pm

Re: Instructions for adding 250k baud rate support in OS X

Sat Mar 29, 2014 12:40 pm

I thought this was interesting, but it turns out that boards like the RAMBO do not use the FTDI chipset any more for USB serial and use the ATmega 16u2 instead. This uses the standard USB COM driver, so the specific information for the FTDI chip does not apply.

JoeJ
Posts: 1435
Joined: Sun Feb 16, 2014 10:52 am

Re: Instructions for adding 250k baud rate support in OS X

Tue Apr 01, 2014 7:50 pm

Hmm… ok well for the sake of having a productive thread, what else might be required to add support for the 250000 baud rate? Or is that already natively supported through the standard USB COM driver?

I've been testing this out on my own with a few C++ programs and none of them seem to be able to correctly communicate at 250000 bps. It either hangs or transmits complete garbage. If anyone has ideas, let's try to compile them here. Maybe we can help out the devs!

jsc
Posts: 39
Joined: Wed Mar 12, 2014 2:21 pm

Re: Instructions for adding 250k baud rate support in OS X

Tue Apr 01, 2014 9:36 pm

Well, just setting the firmware to 250000 and talking to it through Repetier Host works just fine. So no further Mac side drivers are needed. It is only the details with how Simplify3D is connecting that seems to be having issues.

You didn't say what board you were trying to connect to, what firmware, and if it had been updated to speak 250k.

JoeJ
Posts: 1435
Joined: Sun Feb 16, 2014 10:52 am

Re: Instructions for adding 250k baud rate support in OS X

Wed Apr 02, 2014 6:18 am

I'm trying to isolate the possible problem sources, so right now I am just using a standard Arduino with a 20-line program that creates a new Serial connection at 250000 bps and then sends data across that connection. Interestingly enough, the Mac Arduino Serial Monitor also does not support 250000...

I am trying to use this class to communicate with the Arduino from my C++ program. I think this is also very similar to what the S3D guys are using, so if we can figure this out I'm sure it would be a big help to them!
http://qt-project.org/doc/qt-5.1/qtseri ... lport.html

I believe the source for that class can be viewed here:
https://qt.gitorious.org/qt/qtserialpor ... t_unix_p.h (header)
https://qt.gitorious.org/qt/qtserialpor ... t_unix.cpp (source)

From the header, it looks like this class uses the operating system's termios.h file. I found this on my Mac and of course it is missing any mention of the 250000 bps baud rate.

So right now I'm thinking the steps that would be required are
  • Edit termios.h to include "#define B250000 250000" right below the "#define B230400 230400" entry (line 346 on my OS). You can do a spotlight search to find where termios.h is stored on your system. Would also need to verify that this is actually the same termios.h file that gets included when building the QSerialPort library.
  • Edit the qserialport_unix.cpp file to include an entry for 250000. This would be added at line 1270 and would look like:

Code: Select all

#ifdef B250000
    baudRateMap.insert(250000, B250000);
#endif
Hopefully that is all that would be needed. I'm starting to think the root of the problem is that termios.h doesn't include a 250000 bps entry, so any libraries that use the native operating system implementation of termios won't have this option available.

Return to “General Discussion and Tips”