Hi,

I'm having trouble using the Stronglink SL500 RFID reader with OpenBSD.
The SL500 is a USB based RFID reader that attaches to ucom. When I
write data to it and try to read the response, I'm often getting
wrong results. Sometimes the program even lock and unplugging the
device is the only option. I'm using the test program attached below.
This program should produce the following output (as it always does on
Linux):

$ ./test
received: 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00 0x05
received: 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00 0x05


When I run the program on OpenBSD-current (AMD64) I get the following:

$ ./test
received: 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00 0x05
received: 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00 0x05
$ ./test
received: 0x0a 0xbb 0x06 0x00 0x00 0x00 0x07 0x01 0x02 0x04
received: 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00 0x05
$ ./test
received: 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00 0x05
received: 0x0a 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00
$ ./test
received: 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00 0x05
received: 0x0a 0xaa 0xbb 0x06 0x00 0x11 0x12 0x07 0x01 0x00


In the output above the first run is correct. In the second run the
first response is incorrect. In the third and fourth run the second
response is incorrect. Any suggestions what is wrong? To me it looks
like a bug in ucom or uslcom, but I could also be doing something
wrong...

I've included the test program, lsusb output and dmesg output below.


Kind regards,


Martijn Rijkeboer



Test program
============

#include <fcntl.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>

int open_port(void) {
    int fd = open("/dev/cuaU0", O_RDWR | O_NONBLOCK);  // OpenBSD
    //int fd = open("/dev/ttyUSB0", O_RDWR | O_NONBLOCK);  // Linux
    if (fd == -1) {
        perror("can't open port");
    } else {
        fcntl(fd, F_SETFL, 0);
    }

    struct termios options;
    tcgetattr(fd, &options);
    cfsetispeed(&options, B19200);
    cfsetospeed(&options, B19200);
    options.c_cflag |= (CLOCAL | CREAD);
    options.c_cflag &= ~CSTOPB;
    cfmakeraw(&options);
    tcsetattr(fd, TCSANOW, &options);
    return fd;
}

void send_led_green(int fd) {
unsigned char data[] = {0xaa,0xbb,0x06,0x00,0x00,0x00,0x07,0x01,0x02,0x04};
    write(fd, data, sizeof(data));
}

void send_led_red(int fd) {
unsigned char data[] = {0xaa,0xbb,0x06,0x00,0x00,0x00,0x07,0x01,0x01,0x07};
    write(fd, data, sizeof(data));
}

void recv_led(int fd) {
    unsigned char actual[10];
    read(fd, &actual, sizeof(actual));
    printf("received: ");
    printf("0x%02x ", actual[0]);
    printf("0x%02x ", actual[1]);
    printf("0x%02x ", actual[2]);
    printf("0x%02x ", actual[3]);
    printf("0x%02x ", actual[4]);
    printf("0x%02x ", actual[5]);
    printf("0x%02x ", actual[6]);
    printf("0x%02x ", actual[7]);
    printf("0x%02x ", actual[8]);
    printf("0x%02x ", actual[9]);
    printf("\n");
}

int main() {
    int fd = open_port();

    send_led_green(fd);
    recv_led(fd);

    send_led_red(fd);
    recv_led(fd);

    close(fd);
}



$ lsusb
=======
Bus 000 Device 001: ID 1b6f:0000
Bus 001 Device 001: ID 1b6f:0000
Bus 002 Device 001: ID 1002:0000
Bus 003 Device 001: ID 1002:0000
Bus 004 Device 001: ID 1002:0000
Bus 004 Device 002: ID 05ac:1006 Apple, Inc. Hub in Aluminum Keyboard
Bus 004 Device 003: ID 046d:c069 Logitech, Inc. M500 Laser Mouse
Bus 004 Device 004: ID 05ac:0221 Apple, Inc. Aluminum Keyboard (ISO)
Bus 005 Device 001: ID 1002:0000
Bus 006 Device 001: ID 1002:0000
Bus 006 Device 002: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Bus 007 Device 001: ID 1002:0000



$ lsusb -v -s 6:2
=================
Bus 006 Device 002: ID 10c4:ea60 Cygnal Integrated Products, Inc. CP210x UART Bridge / myAVR mySmartUSB light
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  idVendor           0x10c4 Cygnal Integrated Products, Inc.
  idProduct          0xea60 CP210x UART Bridge / myAVR mySmartUSB light
  bcdDevice            1.00
  iManufacturer           1 Silicon Labs
  iProduct                2 CP2102 USB to UART Bridge Controller
  iSerial                 3 0001
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0
      bInterfaceProtocol      0
      iInterface              2 CP2102 USB to UART Bridge Controller
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
Device Status:     0x0000
  (Bus Powered)



$ dmesg
=======

OpenBSD 6.0-current (GENERIC.MP) #2400: Sun Aug 28 12:30:07 MDT 2016
    dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 8553889792 (8157MB)
avail mem = 8290164736 (7906MB)
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.4 @ 0xf0100 (59 entries)
bios0: vendor Award Software International, Inc. version "F7" date 10/22/2012
bios0: Gigabyte Technology Co., Ltd. GA-970A-UD3
acpi0 at bios0: rev 0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP MSDM HPET MCFG EUDS MATS TAMG APIC MATS SSDT
acpi0: wakeup devices USB0(S3) USB1(S3) USB2(S3) USB3(S3) USB4(S3) USB5(S3) USB6(S3) SBAZ(S4) PEX0(S5) PEX1(S5) PEX2(S5) PEX3(S5) P2P_(S5) PCE2(S4) PCE3(S4) PCE4(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpihpet0 at acpi0: 14318180 Hz
acpimcfg0 at acpi0 addr 0xe0000000, bus 0-255
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: AMD FX(tm)-4100 Quad-Core Processor, 20295.83 MHz
cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,AES,XSAVE,AVX,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TOPEXT,ITSC cpu0: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 16-way L2 cache, 8MB 64b/line 64-way L3 cache cpu0: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative cpu0: DTLB 32 4KB entries fully associative, 32 4MB entries fully associative
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 8 var ranges, 88 fixed ranges
cpu0: apic clock running at 201MHz
cpu0: mwait min=64, max=64, IBE
cpu1 at mainbus0: apid 1 (application processor)
cpu1: AMD FX(tm)-4100 Quad-Core Processor, 3624.12 MHz
cpu1: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,AES,XSAVE,AVX,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TOPEXT,ITSC cpu1: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 16-way L2 cache, 8MB 64b/line 64-way L3 cache cpu1: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative cpu1: DTLB 32 4KB entries fully associative, 32 4MB entries fully associative
cpu1: smt 0, core 1, package 0
cpu2 at mainbus0: apid 2 (application processor)
cpu2: AMD FX(tm)-4100 Quad-Core Processor, 3624.12 MHz
cpu2: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,AES,XSAVE,AVX,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TOPEXT,ITSC cpu2: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 16-way L2 cache, 8MB 64b/line 64-way L3 cache cpu2: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative cpu2: DTLB 32 4KB entries fully associative, 32 4MB entries fully associative
cpu2: smt 0, core 3, package 0
cpu3 at mainbus0: apid 3 (application processor)
cpu3: AMD FX(tm)-4100 Quad-Core Processor, 3624.12 MHz
cpu3: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,POPCNT,AES,XSAVE,AVX,NXE,MMXX,FFXSR,PAGE1GB,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,XOP,SKINIT,WDT,FMA4,NODEID,TOPEXT,ITSC cpu3: 64KB 64b/line 2-way I-cache, 16KB 64b/line 4-way D-cache, 2MB 64b/line 16-way L2 cache, 8MB 64b/line 64-way L3 cache cpu3: ITLB 48 4KB entries fully associative, 24 4MB entries fully associative cpu3: DTLB 32 4KB entries fully associative, 32 4MB entries fully associative
cpu3: smt 0, core 2, package 0
ioapic0 at mainbus0: apid 8 pa 0xfec00000, version 21, 24 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 7 (PEX0)
acpiprt2 at acpi0: bus -1 (PEX1)
acpiprt3 at acpi0: bus -1 (PEX2)
acpiprt4 at acpi0: bus -1 (PEX3)
acpiprt5 at acpi0: bus 6 (P2P_)
acpiprt6 at acpi0: bus 1 (PCE2)
acpiprt7 at acpi0: bus -1 (PCE3)
acpiprt8 at acpi0: bus 2 (PCE4)
acpiprt9 at acpi0: bus -1 (PCE5)
acpiprt10 at acpi0: bus -1 (PCE6)
acpiprt11 at acpi0: bus 3 (PCE7)
acpiprt12 at acpi0: bus 4 (PCE9)
acpiprt13 at acpi0: bus 5 (PCEA)
acpiprt14 at acpi0: bus -1 (PCEB)
acpiprt15 at acpi0: bus -1 (PCEC)
acpiprt16 at acpi0: bus -1 (PCED)
acpicpu0 at acpi0: C2(0@100 io@0x841), C1(@1 halt!), PSS
acpicpu1 at acpi0: C2(0@100 io@0x841), C1(@1 halt!), PSS
acpicpu2 at acpi0: C2(0@100 io@0x841), C1(@1 halt!), PSS
acpicpu3 at acpi0: C2(0@100 io@0x841), C1(@1 halt!), PSS
acpibtn0 at acpi0: PWRB
"PNP0C14" at acpi0 not configured
cpu0: 20295 MHz: speeds: 3600 3300 2500 1700 1400 MHz
pci0 at mainbus0 bus 0
0:0:0: mem address conflict 0xe0000000/0x20000000
pchb0 at pci0 dev 0 function 0 vendor "ATI", unknown product 0x5a14 rev 0x02
ppb0 at pci0 dev 2 function 0 "ATI SR5690 PCIE" rev 0x00: msi
pci1 at ppb0 bus 1
radeondrm0 at pci1 dev 0 function 0 "ATI Radeon HD 4350" rev 0x00
drm0 at radeondrm0
radeondrm0: msi
azalia0 at pci1 dev 0 function 1 "ATI Radeon HD 4000 HD Audio" rev 0x00: msi
azalia0: no supported codecs
ppb1 at pci0 dev 4 function 0 "ATI SR5690 PCIE" rev 0x00: msi
pci2 at ppb1 bus 2
xhci0 at pci2 dev 0 function 0 "Etron xHCI" rev 0x01: msi
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 "Etron xHCI root hub" rev 3.00/1.00 addr 1
ppb2 at pci0 dev 7 function 0 "ATI SR5690 PCIE" rev 0x00: msi
pci3 at ppb2 bus 3
em0 at pci3 dev 0 function 0 "Intel 82574L" rev 0x00: msi, address 68:05:ca:05:7d:fa
ppb3 at pci0 dev 9 function 0 "ATI SR5690 PCIE" rev 0x00: msi
pci4 at ppb3 bus 4
re0 at pci4 dev 0 function 0 "Realtek 8168" rev 0x06: RTL8168E/8111E-VL (0x2c80), msi, address 50:e5:49:c6:de:47
rgephy0 at re0 phy 7: RTL8169S/8110S/8211 PHY, rev. 5
ppb4 at pci0 dev 10 function 0 "ATI SR5690 PCIE" rev 0x00: msi
pci5 at ppb4 bus 5
xhci1 at pci5 dev 0 function 0 "Etron xHCI" rev 0x01: msi
usb1 at xhci1: USB revision 3.0
uhub1 at usb1 "Etron xHCI root hub" rev 3.00/1.00 addr 1
ahci0 at pci0 dev 17 function 0 "ATI SBx00 SATA" rev 0x40: apic 8 int 19, AHCI 1.2
ahci0: port 1: 6.0Gb/s
scsibus1 at ahci0: 32 targets
sd0 at scsibus1 targ 1 lun 0: <ATA, SAMSUNG SSD 830, CXM0> SCSI3 0/direct fixed naa.5002538043584d30
sd0: 244198MB, 512 bytes/sector, 500118192 sectors, thin
ohci0 at pci0 dev 18 function 0 "ATI SB700 USB" rev 0x00: apic 8 int 18, version 1.0, legacy support
ehci0 at pci0 dev 18 function 2 "ATI SB700 USB2" rev 0x00: apic 8 int 17
usb2 at ehci0: USB revision 2.0
uhub2 at usb2 "ATI EHCI root hub" rev 2.00/1.00 addr 1
ohci1 at pci0 dev 19 function 0 "ATI SB700 USB" rev 0x00: apic 8 int 18, version 1.0, legacy support
ehci1 at pci0 dev 19 function 2 "ATI SB700 USB2" rev 0x00: apic 8 int 17
usb3 at ehci1: USB revision 2.0
uhub3 at usb3 "ATI EHCI root hub" rev 2.00/1.00 addr 1
piixpm0 at pci0 dev 20 function 0 "ATI SBx00 SMBus" rev 0x42: polling
iic0 at piixpm0
spdmem0 at iic0 addr 0x52: 4GB DDR3 SDRAM PC3-10600
spdmem1 at iic0 addr 0x53: 4GB DDR3 SDRAM PC3-10600
pciide0 at pci0 dev 20 function 1 "ATI SB700 IDE" rev 0x40: DMA, channel 0 configured to compatibility, channel 1 configured to compatibility
atapiscsi0 at pciide0 channel 0 drive 1
scsibus2 at atapiscsi0: 2 targets
cd0 at scsibus2 targ 0 lun 0: <TSSTcorp, CD/DVDW SH-S183L, SB01> ATAPI 5/cdrom removable
cd0(pciide0:0:1): using PIO mode 4, DMA mode 2, Ultra-DMA mode 2
azalia1 at pci0 dev 20 function 2 "ATI SBx00 HD Audio" rev 0x40: apic 8 int 16
azalia1: codecs: Realtek/0x0889
audio0 at azalia1
pcib0 at pci0 dev 20 function 3 "ATI SB700 ISA" rev 0x40
ppb5 at pci0 dev 20 function 4 "ATI SB600 PCI" rev 0x40
pci6 at ppb5 bus 6
fxp0 at pci6 dev 7 function 0 "Intel 8255x" rev 0x05, i82558: apic 8 int 21, address 00:a0:c9:d5:40:72
inphy0 at fxp0 phy 1: i82555 10/100 PHY, rev. 0
"VIA VT6306 FireWire" rev 0xc0 at pci6 dev 14 function 0 not configured
ohci2 at pci0 dev 20 function 5 "ATI SB700 USB" rev 0x00: apic 8 int 18, version 1.0, legacy support
ppb6 at pci0 dev 21 function 0 "ATI SB800 PCIE" rev 0x00: msi
pci7 at ppb6 bus 7
ohci3 at pci0 dev 22 function 0 "ATI SB700 USB" rev 0x00: apic 8 int 18, version 1.0, legacy support
ehci2 at pci0 dev 22 function 2 "ATI SB700 USB2" rev 0x00: apic 8 int 17
usb4 at ehci2: USB revision 2.0
uhub4 at usb4 "ATI EHCI root hub" rev 2.00/1.00 addr 1
pchb1 at pci0 dev 24 function 0 "AMD AMD64 15/0xh Link Cfg" rev 0x00
pchb2 at pci0 dev 24 function 1 "AMD AMD64 15/0xh Address Map" rev 0x00
pchb3 at pci0 dev 24 function 2 "AMD AMD64 15/0xh DRAM Cfg" rev 0x00
km0 at pci0 dev 24 function 3 "AMD AMD64 15/0xh Misc Cfg" rev 0x00
pchb4 at pci0 dev 24 function 4 "AMD AMD64 15/0xh CPU Power" rev 0x00
pchb5 at pci0 dev 24 function 5 "AMD AMD64 15/0xh Host" rev 0x00
usb5 at ohci0: USB revision 1.0
uhub5 at usb5 "ATI OHCI root hub" rev 1.00/1.00 addr 1
usb6 at ohci1: USB revision 1.0
uhub6 at usb6 "ATI OHCI root hub" rev 1.00/1.00 addr 1
isa0 at pcib0
isadma0 at isa0
pckbc0 at isa0 port 0x60/5 irq 1 irq 12
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
it0 at isa0 port 0x2e/2: IT8720F rev 8, EC port 0x228
usb7 at ohci2: USB revision 1.0
uhub7 at usb7 "ATI OHCI root hub" rev 1.00/1.00 addr 1
usb8 at ohci3: USB revision 1.0
uhub8 at usb8 "ATI OHCI root hub" rev 1.00/1.00 addr 1
uhub9 at uhub4 port 1 "Apple, Inc. Keyboard Hub" rev 2.00/96.15 addr 2
uhidev0 at uhub9 port 1 configuration 1 interface 0 "Logitech USB Laser Mouse" rev 2.00/56.01 addr 3
uhidev0: iclass 3/1
ums0 at uhidev0: 8 buttons, Z and W dir
wsmouse0 at ums0 mux 0
uhidev1 at uhub9 port 2 configuration 1 interface 0 "Apple, Inc Apple Keyboard" rev 2.00/0.69 addr 4
uhidev1: iclass 3/1
ukbd0 at uhidev1: 8 variable keys, 5 key codes, country code 13
wskbd0 at ukbd0: console keyboard
uhidev2 at uhub9 port 2 configuration 1 interface 1 "Apple, Inc Apple Keyboard" rev 2.00/0.69 addr 4
uhidev2: iclass 3/0
uhid0 at uhidev2: input=1, output=0, feature=0
uslcom0 at uhub6 port 3 "Silicon Labs CP2102 USB to UART Bridge Controller" rev 1.10/1.00 addr 2
ucom0 at uslcom0 portno 0
vscsi0 at root
scsibus3 at vscsi0: 256 targets
softraid0 at root
scsibus4 at softraid0: 256 targets
root on sd0a (8fd54f0b35b2d511.a) swap on sd0b dump on sd0b
radeondrm0: 1920x1200
wsdisplay0 at radeondrm0 mux 1: console (std, vt100 emulation), using wskbd0
wsdisplay0: screen 1-5 added (std, vt100 emulation)
acpi0: PM1 stuck (en 0x121 st 0x1), clearing

Reply via email to