wiki:Docs/Prog/Manual/DeviceSupport/USB

USB Support

The Cardinal 825 supports many USB devices such as Flash Drives, Printers (Cardinal supported only!), and keyboards.

825 USB A Ports (2)

USB Mass Storage

The 825 supports USB flash storage devices formatted with the FAT (file allocation table) and FAT32 file systems. From the serial command line when a USB storage device is inserted the display will appear similar to:

Screenshot of shell after inserting USB.

Use the mount command to access files on the USB flash drive:

mount –t vfat /dev/sda1 /mnt/fl1

The files will then appear in the path /mnt/fl1 such as:

Some USB flash drives may be formatted without having a partition table. In this case the mount command is:

mount –t vfat /dev/sda /mnt/fl1

If a second USB flash drive is connected before the first one is unmounted and removed or if the first one is removed without an proper unmount the new drive will appear as sdb1 or sdb.

mount –t vfat /dev/sdb1 /mnt/fl2

or without partition table:

mount –t vfat /dev/sdb /mnt/fl2

To find out the status of connected USB devices you may view the virtual file /proc/bus/usb/devices

$ cat /proc/bus/usb/devices

T:  Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#=  1 Spd=480 MxCh= 1
B:  Alloc=  0/800 us ( 0%), #Int=  1, #Iso=  0
D:  Ver= 2.00 Cls=09(hub  ) Sub=00 Prot=01 MxPS=64 #Cfgs=  1
P:  Vendor=1d6b ProdID=0002 Rev= 2.06
S:  Manufacturer=uClinux 2.6.29 ehci_hcd
S:  Product=Freescale On-Chip EHCI Host Controller
S:  SerialNumber=fsl-ehci.0
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   4 Ivl=256ms

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=12  MxCh= 4
D:  Ver= 1.10 Cls=09(hub  ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=0451 ProdID=2046 Rev= 1.25
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub  ) Sub=00 Prot=00 Driver=hub
E:  Ad=81(I) Atr=03(Int.) MxPS=   1 Ivl=255ms

T:  Bus=01 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=0781 ProdID=5150 Rev= 0.10
S:  Manufacturer=SanDisk Corporation
S:  Product=Cruzer Mini
S:  SerialNumber=20043515110EDEA28110
C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms

In the example above there is a SanDisk Cruzer Mini flash drive attached.

Console messages after USB flash mount

The file manager may be used to access USB flash drives. When the /mnt/fl1 folder is selected the file manager will automatically perform the mount command.

Accessing USB storage from a program

system("mount -t vfat /dev/sda1 /mnt/fl1");

FILE* file = fopen("/mnt/fl1/outfile.txt", "w");
if(file != NULL)
{
   fprintf(file, "Gross Weight %g\r\n", wtdata[1].grosswt);
   fclose(file);
}

system("umount /mnt/fl1");

This example will mount the flash device, write a file to it, and then unmount the device. The USB storage device should not be removed or replaced while it is mounted. Programs should be written to mount and unmount each time they write to the flash, or there should be some command provided in the program so that the operator can unmount the drive to replace it.

USB Keyboards

As of kernel 2008-11-13 many USB keyboards should work with the 825. Simply plug the keyboard into an 825 USB connection.

Console messages after inserting USB keyboard

Applications using the lib825 functions such as [[lib825:source:trunk/kypdbeep.cpp#L78 ReadKeypad]] or [[lib825:source:trunk/form.cpp#L1027 FormLCD] will automatically work with the USB keyboard. To test the keyboard without any app running type some characters on the keyboard and type:

# cat /dev/usbkybd

Output:

Console test of USB keyboard

The characters typed on the USB keyboard should show on the serial port terminal.

USB Printing

usblp.ko device driver module for usb printing support. Type:

# modprobe usblp

Kernel should be configured with /dev/usblp0 device node. If not type:

# mknod /tmp/usblp0 c 180 0

/dev is in read-only file system so device node can be created under /tmp instead

This creates the character device driver with major number 180 and minor number 0. This should work unmodified with USB printers that accept raw text for printing using a default font.

A simple test is:

# echo “ABCDEFGH” > /dev/usblp0
'''or'''
# echo “ABCDEFGH” > /tmp/usblp0

Applications may be written to open “/dev/usblp0” to print to USB printer 0 instead of “/dev/ttyS1” to open COM2

Compatible USB Printers

  • Okidata Microline 320 Turbo - Older versions of this printer do not have USB port
  • Hewlett Packard DeskJet 830C - Does not print page until page is complete so form feed or extra line feeds are required to finish the print Text output only (No graphics)
  • Epson TM-U590 - Slip printer Escape codes can be sent to do reverse mode printing - Form feed will then eject slip back out
  • Brother HL-2270DW - Laser Printer Does not print page until page is complete so form feed or extra line feeds are required to finish the print Text output only (No graphics unless custom program is written to send special codes to printer)

USB Hubs

Many standard models of USB 2.0 hub will work to allow more devices to be connected simultaneously.

825 USB B Port (1)

USB to PC communications

To load the driver in the 825 for USB to PC communications from a connected terminal type:

# modprobe g_serial use_acm=1

This can also be performed from within a custom application program.

system("modprobe g_serial use_acm=1");

When the USB cable is connected from the 825 to the PC it will be recognized by Windows and if the driver is not already installed Windows will prompt for it. Refer to the attachments at the bottom of this page to download Windows driver files.

When the driver is installed the PC will appear to have another COM port. For testing on the PC you can then open a communications program such as HyperTerminal and set it to the appropriate COM port (which is actually a USB connection).

On the terminal connection to the indicator type:

# echo “abcdefg” > /dev/ttygserial

“abcdefg” will then appear on the Hyperterm display.

On the terminal connection to the indicator type:

# cat < /dev/ttygserial

In HyperTerminal, type:

123456<CR>

The received characters “123456” from the PC will then be displayed on the terminal connected to the 825.

Custom 825 application programs may use serial communications code to send and receive data over USB in much the same way as with the COM ports.

Last modified 12 months ago Last modified on 04/25/23 06:59:48

Attachments (7)

Download all attachments as: .zip

Note: See TracWiki for help on using the wiki.