Can't find Serial Number attribute for PL2303 device in linux - c#

When i run the following command after connecting PL2303 USB to serial converter to my ubuntu system:
dmesg | grep ttyUSB
i get:
usb 1-2: pl2303 converter now attached to ttyUSB0
then i run:
udevadm info -a -n /dev/ttyUSB0
i get:
looking at parent device '/devices/pci0000:00/0000:00:14.0/usb1/1-2':
KERNELS=="1-2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{bMaxPower}=="100mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0400"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="1"
ATTRS{configuration}==""
ATTRS{devnum}=="27"
ATTRS{devpath}=="2"
ATTRS{idProduct}=="2303"
ATTRS{idVendor}=="067b"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Prolific Technology Inc. "
ATTRS{maxchild}=="0"
ATTRS{product}=="USB-Serial Controller D"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="removable"
ATTRS{speed}=="12"
ATTRS{urbnum}=="20"
ATTRS{version}==" 1.10"
But no
ATTRS{serial}
is found for the above PL2303 USB to serial converter.
Can anyone please tell me why? I get the serial attribute for all other USB devices

The datasheet for the PL2303 serial converter chip includes a description of the EEPROM configuration data for the chip on page 11.
The EEPROM can specify the USB product and vendor IDs for the chip, so instead of using the generic USB-to-serial converter ID, someone using this chip in their products can use an ID that is specific to their product, allowing for seamless auto-detection and use of the product-specific driver, if desired. One would expect that the serial number might also be stored in that EEPROM. But there is no place for a serial number in the EEPROM data layout.
In fact, the entire datasheet does not document any way to retrieve an unique serial number from this serial converter at all. So I must conclude that this serial converter chip series simply does not have unique serial numbers, at least not in its earlier chip revisions (the datasheet is from year 2005).

Related

How to find USB HID DevicePath?

I've been working on USB HID Device in embedded system and C# for a while. I decided to use USBHid library in C#. I got the ideal result with this library. But I have a problem. While defining the USB in the USBHid library, the following code is sufficient in the project of the library that I found on the internet.
public UsbHidDevice Device;
Device = new UsbHidDevice(vvvv,pppp);
However, when I use the same library, it asks me for an expression in the following format.
public UsbHidDevice Device; string vidandpid =
"\\hid#vid_0000&pid_0000&mi_00#a&0&000000000&1&0000#{eeof37d0-1963-47k4-aa41-74476db7uf49}";
Device = new UsbHidDevice(vidandpid);
I adapted this format for my own HID device, but without success. How should this string expression be? I am open to your views. Thank you from now.
How to find USB HID DevicePath?
I gave up on USBHID library and found solution with HidLibrary library. As far as I understand, HidLibrary falls short on some issues.
Here I am sharing the C# code that I linked with HidLibrary. Thank you for all the replies.
device = HidDevices.Enumerate(VendorID, ProductID).FirstOrDefault();
if (device != null)
{
device.OpenDevice();
device.Inserted += DeviceAttachedHandler;
device.Removed += DeviceRemovedHandler;
device.MonitorDeviceEvents = true;
device.ReadReport(myfunction);
}
else { RtBox_Feedback.AppendText("NOT DEVICE!"); }
\\hid#vid_0000&pid_0000&mi_00#a&0&000000000&1&0000#{eeof37d0-1963-47k4-aa41-74476db7uf49} - is a device interface for the {eeof37d0-1963-47k4-aa41-74476db7uf49} interface. It is almost always unique and semi-random for each device. It also may change if yore put device in another USB slot. This string may be used as path to open this "file" with CreateFile Win32 API and talk with device by means of interface-specific IOCTLs. More info here.
For HID devices Windows have another device interface GUID - GUID_DEVINTERFACE_HID - {4D1E55B2-F16F-11CF-88CB-001111000030}
You can use CM_Get_Device_Interface_ListW or SetupDiGetClassDevs/SetupDiEnumDeviceInterfaces/SetupDiGetDeviceInterfaceDetail APIs to enumerate device interfaces by interface GUID or by device Instance ID.
Mentioned "USBHid library in C#" may already have code that doing such enumeration and filtering by HID deivce VID/PID but I cannot say it for sure since you haven't added link to the code of this library. :)

BluetoothLEAdvertisementWatcher doesn't receive Advertisement payload

I'm trying send Information from Device A to Device B using Bluetooth Low Energy Advertisements.
In order to receive the broadcasts, I'm using Windows UWP's Bluetooth Low Energy Library (https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/ble-beacon)
My received advertisements should include Information, but they don't. I tried to use BluetoothLEAdvertisementDataSection and BluetoothLEManufacturerData. Both aren't working. If I receive the Advertisement, the BluetoothLEAdvertisementDataSection doesn't include my information and the BluetoothLEManufacturerData is just empty.
This is what I receive:
Address: 0x2462ABE13A7E; Name:CH1234; RSSI: -49
ManufacturerDataLength: 0
ManufacurerData: []
DataSectionsLength: 4
DataSections: [0x06] [0x43-48-31-32-33-34] [0x03] [0x20-00-40-00]
The DataSections are about DataType 0x01, DataType 0x09, DataType 0x0A and 0x12
Is there any way to get the raw advertisement message? Or any other way to get this information?
I tried to receive Information from Advertisements using bluepy on Linux and it is working. Therefore the problem must be within this library.
This is my Code: https://pastebin.com/rxcrjhpj
There is not mutch. Just the BluetoothLEAdvertisementWatcher and printing the received Information.
///Edit
I fixxed it. The mistake was within sending the broadcast.
I use nkolban's ESP32 BLE Library, there are two functions. One called "BLEAdvertisementData.setManufacturerData" and the other one "BLEAdvertisementData.addData". However by using "addData" it looks like the broadcast frame gets messed up somehow. It's working if I just use "setManufacturerData" instead of "addData"

Kick Cash Drawer using Control Code

I am working with Epson Thermal printer and Cash Drawer. Cash Drawer is connected with the printer. Reference to http://keyhut.com/popopen.htm, the code to kick cash drawer is 27,112,0,50,250. I tried to send this code to printer but nothing happens. I used POS for .NET and the printer is registed in SetupPos.
Here is my code:
deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName);
m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo);
m_Printer.Open();
m_Printer.Claim(1000);
m_Printer.DeviceEnabled = true;
//command = "ESC|p|0|25|251";
command = "\x1B|\x70|\x00|\x19|\xFB";
m_Printer.PrintImmediate(PrinterStation.Receipt, command);
//m_Printer.CutPaper(100);
m_Printer.DeviceEnabled = false;
m_Printer.Release();
m_Printer.Close();
Print text is ok, but send code is not working. What can I do? Thanks.
POS for.NET(UnifiedPOS) specification does not support CashDrawer opening by the PrintNormal()/PrintImmediate() method of POSPrinter device.
Since there is a independent CashDrawer device associated with the POSPrinter device, please open() the corresponding device as a CashDrawer and open the drawer with the OpenDrawer() method.
However, depending on the vendor, there is a possibility of supporting usage like you.
I do not have information on whether EPSON POSPrinter supports such usage or not.
Please ask EPSON or your distributor whether or not you can use such a way.
In addition:
Instead of POS for.NET, there is a way to install and use a device driver as a regular Windows Printer.
Some vendors offer Windows Printer Driver for receipt printers and also support paper cutting and drawer opening functions.
In EPSON, it is provided under the name Advanced Printer Driver.
The questioner seems to have solved the problem using this.
However, this device driver is often used exclusively with POS for.NET/OPOS/JavaPOS, and when printing, it is necessary to use Windows standard printing API.
The third code from open drawer kick code "ESC|p|0|25|251" to send is actually a symbol to control cash drawer 1 or 2, which is using '0' or '1'. The 0 or 1 symbol in the ASCII table is mapped to decimal 48 or 49. So you need to use the Hex x30 or x31 not x00.
Just to add more info, the forth and the fifth code are the time when the signal kick is ON or OFF by sending decimal (value between 0 to 255) * 2ms.
I hope this solve the problem if you still want to use the cash drawer kick code and attach the device to the printer.

How are PCSC smart card reader 'friendly names' constructed?

I use WinSCard to list all readers, which gives me a list like this:
ASK RDR4x7 0
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 0
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 1
SCM Microsystems Inc. SCR3320 USB Smart Card Reader 2
Which is great, but I have no clue which name belongs to which card reader.
Where do these names come from? How are they constructed?
What I've found up until now: in the registry, there is a HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services key. Under this key, you can find the subkey which matches the card reader's "service" (which I found by querying the WMI registry). For example: the service for the SCM Microsystems Inc. SCR3320 USB Smart Card Reader readers is SCR3XX2K.
This subkey (SCR3XX2K) has another subkey Enum, which has multiple interesting values:
Count: DWORD, the number of readers connected
0, 1, 2: STRING, hardware Device ID
I guess these are the numbers appended to the 'friendly names', but I can't figure out how the name string is constructed. I need this to map hardware Device ID's (which I get through WMI) to their friendly name.
So, what's the pattern used to create a 'friendly name' for a smart card reader, and where do the values come from?
They are a concatination of these 3 attributes:
SCARD_ATTR_VENDOR_NAME
SCARD_ATTR_VENDOR_IFD_TYPE
SCARD_ATTR_DEVICE_UNIT
The TechNet article Smart Card Events documents this in the "Smart Card reader name" section.
SCARD_??? attributes are requested with the SCardGetAttrib function.
The SCARD_ATTR_DEVICE_SYSTEM_NAME attribute returns the friendly name as the ones you get while listing the readers.
The list of SmartCard readers exists in the registry under HKLM\SOFTWARE\Microsoft\Cryptography\Calais\Readers. Readers are added to this list by the INF file of the SCR driver, so during driver installation.
A link between device and reader can be found in the SmartCardReader class {50DD5230-BA8A-11D1-BF5D-0000F805F530} under HKLM\SYSTEM\CurrentControlSet\Control\Class\{50DD5230-BA8A-11D1-BF5D-0000F805F5‌​30}.

.NET or COM HID iCLASS Smart Card Reader

I have coding I almost always use with my Omnikey RFID CardMan 5321 smart cards. Problem is we received new cards today which are marked "HID iCLASS GL" which do not appear to be working well with our coding.
Without going through the whole source, our problem is arising when we are calling the following line, which basically tells us the length of the data:
lResult = SCardTransmit(hCard, 0, bytCommand, lLen, 0, byReadBuffer, iReturnlength)
We are returning only a length of 2, which the data is marked as "x69 x86". Even if I tell it to read all 255 chr's the rest are just marked as null.
Now I know our reader can read these cards since the OMNIKEY Diagnostic tool is showing us the following:
Status: Smart Card Inserted
FW: 5.10
Port: USB
Lib: 1.0
Smart Card Nme: iCLASS 32KS 8x2+16
ART: Valid
Protocol: ISO 15693 (Part 2)
PICCtoPCD: 26,48 kbps
PCDtoPICC: 26,48 kbps
Frequ: 13.56 MHz
As I explained before, everything is working fine in my coding except no data is being returned for my card besides "x69 x86", which is surely not correct.
If anyone has any experience reading from a HID iCLASS card, I would greatly appreciate some feedback on how to. Even if we have to license software, that is ok.
Thanks in advance!
in case you are trying to access physical access data, I would thoroughly check the crypto protocol between reader and host first and also meke sure you are using a reader with teh latest firmware (5.20 for the OMNIKEY 5321).
I would also introduce code to check the card system withour secure communication channel between host and reader application.
Further references:
http://www.hidglobal.com/documents/ok_contactless_developer_guide_an_en.pdf
The reason cause you get a 2 Byte array is cause your command runs on an error so the chip returns only SW1 and SW2 Flag
in your case it's meaning is
x69 --> Command not allowed (further qualification in SW2, see table 17)
x86 --> Command not allowed (no current EF)
So you might proof that your application file on the chip is correctly selected
further information #
http://www.cardwerk.com/smartcards/smartcard_standard_ISO7816-4_5_basic_organizations.aspx#table17

Categories

Resources