USB Host shield Comms question

Good day to all.

Looking for some assistance, so here goes.

I have an USB Host Shield on an Uno. Ran the test apps on Oleg's site, and all responds OK. I have an Inverter/UPS that communicates via USB in Hex. When the unit is connected to host shield, I get all the identifier info OK. "Device descriptor: Descriptor Length: 12 Descriptor type: 01 USB version: 0110 Device class: 00 Device Subclass: 00 Device Protocol: 00 Max.packet size: 08 Vendor ID: 0665 Product ID: 5161 Revision ID: 0002 Mfg.string index: 03 Prod.string index: 01 Serial number index: 00 Number of conf.: 01" etc. etc.

I need to send Hex commands over the port to the device and listen for the response. In standard serial it seems pretty easy, with things like Serial.write and Serial.read.

After two weeks now of struggling I am asking for some direction. What commands do I use to communicate serially with the device? I have gone through a thousand samples, but none seems to do simple serial comms over USB.

Any assistance and/or samples would be greatly appreciated.

Riaanh: I need to send Hex commands over the port to the device and listen for the response. In standard serial it seems pretty easy, with things like Serial.write and Serial.read.

do you have the exact specs for your Inverter/UPS and the expected protocol?

Hi J-M-L.

First of all, THANKS for the prompt response.

Yes I do, there are a couple of Hex items I can send to either request info or modify settings.

First example I would like to get going is a query on the following:

"QPIGS:
Device general status parameters inquiry
Computer: QPIGS "

Some other sample:

QMOD:
Device Mode inquiry
Computer: QMOD
Device: (M
Power On Mode P
Standby Mode S
Line Mode L
Battery Mode B
Fault Mode F
Power saving Mode H

Example: Computer: QMOD
DEVICE: (L Means: the current DEVICE mode is Grid mode.

I hope that makes sense?

I understand you know which ASCII string to send to the UPS.

Standard USB devices are normally supported by class drivers. The question is do you have details on the protocol itself things like "Asynchronous Serial over USB" (CDC ACM-class device)

Check an example of communication over USB with a Navibee GM720 GPS receiver based on SiRF Star III chipset and PL2303 USB to serial converter

To the best of my knowledge it is standard Asynchronous over USB. Thus far Confirmed the following:

Baud rate 2400 Start bit 1 Data bit 8 Parity bit N Stop bit 1

I have had a quick look at the Navibee page end of last week, but the Github sketch link is broken.

Thanks so far, I will update if I can confirm Async

standard Asynchronous over USB should make things easy... conceptually it's almost like Serial

Thanks for taking the time to respond to a newbie/id10t post.

As you could have noticed by now, this is all new to me, being an electronic/hardware tech, the tech part is easy for me, but the software side NOT so much.

On one of my other projects, made great headway, but those are standard things like addressing A and D lines, displaying and logging Voltages, Current, 4X20 LCD's etc.

When I use Term session with Async and the settings as above I get the appropriate responses.

However in C++/Arduino I still cannot find the command to send data or receive data.

All the sample codes I have looked at relates back to rcode, uint_8 and uint_16, yet I cannot for the life of me figure out how to send a simple string to USB and read back the answer. >:(

I maybe need to add, that the USB is seen as HID, and according to some sources the Class is different?

When I use Term session with Async and the settings as above I get the appropriate responses.

have you tried just using Serial connection then? just connect to your Inverter/UPS by using an USB to TTL UART 6PIN Module Serial Converter?

Nope, have not tried yet. Bought the USB Host Shield full of expectation to communicate with HIDUSB. All the samples, ie. Mouse, Memory stick etc comms good. If I can just get a sample to see the instructions somewhere that contain the basics like:

USB.begin(9600); if(USB.available())

USB.write(0x57);

Serial.println(USB.read(), HEX);

if(USB.available()){ USB_Byte=USB.read(); Etc.

When I look at your Device descriptor

Device class: 00
Device Subclass: 00
Device Protocol: 00

The 3 zeros means that you don't have an HID device otherwise Base Class should be 0x03 (HID – Human Interface Device)

go check the USB Class Codes

if you connect a USB cable between your computer and the Inverter/UPS and run a Terminal session connecting to the Serial Port (such as with CoolTerm or equivalent) and set the communication parameters to

Baud rate 2400 Start bit 1 Data bit 8 Parity bit N Stop bit 1

are you seeing any communication at all?

Thanks J-M-L

I will run and check again tonight once I get home and respond. Thanks again

OK so I did a couple of testes.

Device class: 00
Device Subclass: 00
Device Protocol: 00

Is still the same on the inverter, but so it is on an USB Mouse and keyboard. I have attached two txt files to display the results in toe seperate USB Sample libraries.
I hope this will help steer me in the right direction.

Inv VS Mouse HID on USB_Desc.txt (1.66 KB)

Inv VS Mouse HID on USBHID_Desc.txt (1.81 KB)

did you try the serial communication?