A simple com sender

Discuss PC Developer and Web Developer projects and features here.
Steve-Matrix
Matrix Staff
Posts: 1415
http://meble-kuchenne.info.pl
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 191 times
Been thanked: 331 times

Re: A simple com sender

Post by Steve-Matrix »

That's interesting. Thanks for sharing.

For info, our Serial COM component uses standard Windows calls to transfer data via the serial port. It makes no distinction between virtual COM ports and real COM ports, so there is no option to set the amount of serial information sent within the USB packets.

User avatar
Nico595
Posts: 40
Joined: Tue Jul 04, 2023 4:17 pm
Has thanked: 7 times
Been thanked: 3 times

Re: A simple com sender

Post by Nico595 »

Hello Steve,

Thank you.
I like work to discover new things :)

During the test I thought 1 Byte (Payload) per DATA usb packet was relative at the Windows driver or maybe, usb speed negotiation between the device and Windows. But if I send a string "ABCDEFG" with HyperTerm, with the same Windows driver, without hardware disconnection, so the same negotiation between the device and Windows, I receive "ABCDEFG" in one DATA usb packet.

So it's not relating at the Windows driver layer and not relating at the negotiation speed beetwen the device and Windows.

Maybe an expert of usb DATA and Software can we help to understand why Flowcode Pc App send only one Byte (Payload) per DATA usb packet.

Also I though that this way of packaging Data in the DATA usb packet is maybe used by the SCADA layer to secure the data during the transport.
You can probably find this answer if your work with the SCADA Team.

Steve-Matrix
Matrix Staff
Posts: 1415
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 191 times
Been thanked: 331 times

Re: A simple com sender

Post by Steve-Matrix »

The code for sending out data on the serial port is very simple. It opens the port, sends the data, then closes the port. The connection is treated as a COM port and so there are no USB-specific options. It does not "see" a USB device. It "sees" only a COM port and only has access to options related to a COM port (such as start/stop bits and baud rate).

It seems to work fine with other USB-to-Serial drivers and so perhaps there is something unusual with the AT91 implementation you are using that requires Windows apps to use a different mechanism to exchange data other than the Windows generic COM-based functions. I cannot begin to test or resolve this as I do not have the same hardware that you are using, but please share if you have any technical details on the driver and hardware implementation of this USB-to-Serial device.

User avatar
Nico595
Posts: 40
Joined: Tue Jul 04, 2023 4:17 pm
Has thanked: 7 times
Been thanked: 3 times

Re: A simple com sender

Post by Nico595 »

You have right, it's not a parameter of COM Port, I wrote "added a parameter to control the packaging of the data in the DATA usb packet in COM Port", because I don't know where place it in your Software. But if this usb packaging method is not defined somewhere in a layer of the software, I don't know how change this limit of the Payload DATA usb packet. Maybe the Windows driver find many errors of transmit packet when I use Flocode Pc App and downgrade the Payload = 1 Byte only. I don't know.

About USB hardware and software layers, we find very interesting information on the web. My result of the research about the Payload of DATA usb packet is 8 Bytes minimal with 0x0100 USB version (1.5MB/s). But Flowcode PC App send always only 1 Byte per DATA usb packet. HyperTerm and other software that you know load the DATA usb packet with the Payload, 8, 16, 32 or 64 Bytes with the 0x0100 USB version. Up to 1024 Bytes in a same DATA usb packet with USB2 version 0x0200. In my usbDescriptor file I have this define = 0x0100.

You can check it in your home with your hardware and DSLogic Analyser Plus or other Logic Analyser.

I find this information here:
https://www.keil.com/pack/doc/mw/USB/ht ... l#Overview
And in this great documentation here:
https://www.usbmadesimple.co.uk/ums_1.htm
In French:
https://www.abcelectronique.com/acquier/usb1_fr.htm
Last edited by Nico595 on Mon Sep 30, 2024 3:05 pm, edited 3 times in total.

Steve-Matrix
Matrix Staff
Posts: 1415
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 191 times
Been thanked: 331 times

Re: A simple com sender

Post by Steve-Matrix »

Sorry, I think there is some confusion.

The Serial Port component in Flowcode does not expect the port to be USB and so has no options for doing anything relating to USB protocols. It is used when interfacing with RS232-like systems.

You will need to use a different method to communicate with USB devices that use features that are not part of the RS232 group of protocols.

User avatar
Nico595
Posts: 40
Joined: Tue Jul 04, 2023 4:17 pm
Has thanked: 7 times
Been thanked: 3 times

Re: A simple com sender

Post by Nico595 »

I understood Steve, RS232 is not USB and RS232 have not USB parameters. The Windows Usb Serial driver is a Windows link between the Serial Com and the USB.

If you don't know control of the packaging data of the DATA usb packet in your software, it's maybe a downgrade of the communication when I use Flowcode Pc App. But only with Flowcode Pc App, you can see 7 Bytes in the DATA usb packet with HyperTerm.

About the Embedded CdcUsbSerial code I use code from the Atmel library.

User avatar
Nico595
Posts: 40
Joined: Tue Jul 04, 2023 4:17 pm
Has thanked: 7 times
Been thanked: 3 times

Re: A simple com sender

Post by Nico595 »

From the document Part 3 : https://www.usbmadesimple.co.uk/ums_3.htm
Endpoints

Each USB device has a number of endpoints. Each endpoint is a source or sink of data. A device can have up to 16 OUT and 16 IN endpoints.

OUT always means from host to device.

IN always means from device to host.

Endpoint 0 is a special case which is a combination of endpoint 0 OUT and endpoint 0 IN, and is used for controlling the device.
Pipe

A logical data connection between the host and a particular endpoint, in which we ignore the lower level mechanisms for actually achieving the data transfers.
Transactions

Simple transfers of data called 'Transactions' are built up using packets.
If I understand good, Endpoint 0 is the smallest configuration to control the device. MaxPacketSize = 8 Bytes but here MaxPacketSize is 1 Byte for the Payload.
A device can have more than one configuration, though only one at a time, and to change configuration the whole device would have to stop functioning. Different configurations might be used, for example, to specify different current requirements, as the current required is defined in the configuration descriptor.
A device can have one or more interfaces. Each interface can have a number of endpoints and represents a functional unit belonging to a particular class.

Each endpoint is a source or sink of data.
So, the same device can have different configurations (Interfaces and Endpoints) without hardware disconnection.

The question is : why and how Windows USB Driver use probably always Endpoint 0 configuration with Flowcode Pc App ?

I must progress in my job.

Maybe we will answer at this questions later.

Post Reply