Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

cRIO 9067 to recongnize SiLabs USB RS232

Solved!
Go to solution

Hello,

 

I have a cRIO 9067 and would like to interface to an instrument that has a SiLabs USB-RS232 converter.  I can comminicate with this instrument easily on a Windows PC.  I am able to see the device in MAX when its connection the cRIO.  IT shows up under "Devices and Interfaces" as "USB0::0x1FB9::0x0100::121A00A::RAW"  with the Model number and the device description.

 

I've followed the description at this link, but I don't get a ttyUSB# devices.

 

https://decibel.ni.com/content/docs/DOC-34827

 

Is there any chance to get this working on the cRIO as a serial port?

 

 

 

 

Thanks.

0 Kudos
Message 1 of 6
(5,885 Views)

Hello immercd1,

 

Try following the steps followed in the second post here:

 

http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/USB-to-Serial-Not-Working-through-VISA-on-cRI...

 

Let me know if that works for you. 

 

Thanks!

Collin D.
Software Product Manager
0 Kudos
Message 2 of 6
(5,855 Views)

I don't have that file /etc/mdev.conf.

 

Is it possibly in a different location on the 9067?

0 Kudos
Message 3 of 6
(5,832 Views)

I created the file at /etc/mdev.conf with the line:

ttyUSB[0-9]*     root:tty 666

 

restarted the cRIO, but the device still shows up as a usb raw device.

0 Kudos
Message 4 of 6
(5,827 Views)

Hello immercd1,

 

Lots of changes were made in the file structure when the 9067 was released. This document helps outline how to connect to USB devices with the new structure:

 

https://forums.ni.com/t5/NI-Linux-Real-Time-Documents/Creating-Large-USB-Instrument-Networks-with-Pe...

 

Let me know if you have any other questions!

 

Thanks,

Collin D.
Software Product Manager
0 Kudos
Message 5 of 6
(5,816 Views)
Solution
Accepted by topic author immercd1

After some digging, talking with NI Folks, google, and Talking with Folks at lakeshore.com (device vendor) here's what I've piece together on how to get this to work:

 

  • In Linux, usb devices are enumerated automatically, and, by default, will show up as a USB RAW device
  • Once the USB device has been enumerated, it can then, subsequently be linked to a driver
  • Linux determines if and when to link each USB device based on the Device's on Vendor ID (VID) and Model ID (MID). These are typically 3-4 digit hex strings.
  • For the case of the Lakeshore 121 current source, VID=1FB9 MID=100.       I could see these in MAX for the USB Raw Device.
  • There are two levels of drivers for USB-Serial Devices. The first driver: usbserial.ko is a generic driver that handles all USB-Serial devices. This must be loaded for all USB-Serial converters.
  • The second driver is specific to the chipset of the USB-Serial device.       For the cRIO, there are three options that are pre-installed (FTD, SiLabs, and some other)
  • The drivers reside at       /lib/modules/3.2.35-rt52-2.0.0f0/kernel/drivers/usb/serial/ (where the kernel version directory may vary)
  • The Lakeshore 121 use the SI labs CP210x chipset, so we chose this one.
  • The device drives first need to be loaded by Linux. Linux can automatically do this by adding zero length files to the module.autoload.d directory. To do this execute the following:
    • cd /etc/modules.autoload.d
    • touch usbserial
    • touch cp210x
    • reboot cRIO
    • execute dmseg | grep usbserial to confirm that the usbserial driver is loaded
    • execute dmesg | grep cp201x to confirm that the cp210x driver is loaded
  • The next step is to associate our USB device with the cp210x device driver. Remember that linux associates the device with a driver based on VID and MID. Whomever installed the cRIO linux base, I'm sure, knew nothing about the Lakeshore 121 VID and MID.
  • Lakeshore recommended getting the source code for cp210x, adding the VID and MID to the list of recognized devices, recompiling the cp210x.ko file and installing to the cRIO. This would work, but is beyond my current Linux capability.
  • Linux gives the ability to dynamically add MID, VID so that a device can be recongized on the fly
  • When the CP210x driver is loaded, an whole directory struchture is created. Ther is a file in that directory structure called new_id where we can dynamically added VID,MID's.
  • Create a startup script to execute the following command. Be mindful of cr/lf line termination issues between operating systems. It's usually easier just to create the script on the cRIO with the VI editor to avoid any issues.
    • echo 1FB9 100 >/sys/bus/usb-serial/drivers/cp210x/new_id
  • Now on reboot (or execution of the script), you will get a /dev/ttyUSB[0-9] device
  • Unfortunately, the default creation of the ttyUSB[0-9] device does not allow write permission, so we need to create a UDEV rule to automatically give write permission
  • Add the following lines of code to udef.conf in the folder /etc/udev

#typical devices

ttyUSB[0-9]* root:tty 666

  • Create a file named 99-ttyUSB.rules in the folder /etc/udev/rules.d
  • Add this line of code to that file:

KERNEL=="ttyUSB[0-9]*", OWNER="admin", MODE="0666"

 

  • Reboot the cRIO. This should be it! It worked for me.

 

 

 

 

 

 

 

 

Message 6 of 6
(5,606 Views)