Page 2 of 3
Re: Debug: A simple com sender
Posted: Thu Sep 26, 2024 5:24 pm
by Nico595
I tried with more time between the open port and the send data, no change, I always strange data.
With chance I have RS232 on the Lanner and the Shuttle. On the Shuttle, I connected the Logic Analyser on Port Com 1.
When I send String with "U", no problem. I can send "UU", The Pc App send "UU" on Port Com 1 of the PC.
I tried send String "FF", I obtain ".." (01110100)
Data are sometimes good and sometimes bad but always the same. Like this I have a bad corresponding ASCII table.
I replaced the component COM Port in the project but I have the same problem.
I will try again with SendByte and Send Binary macro.
EDIT:
If I use SendByte macro with "85" for "U" it's OK
SendByte "84" for "T" I obtain "15" (10101000)
SendByte "100" for "d" I obtain "13" (11001000)
SendByte "125" for "}" I obtain "A" (10000010)
On the 3 last values, I have the first bit in less. Maybe my trigger, I check it.
It's the normally level of the Port COM 1, with the RS232 I must read the value in invert mode.
So it's OK with Pc APP when I use the Port Com 1 (RS232), confirmed with a sequence of "dT" "dU" Send String.
I come back on the USB serial COM8 and on the same sequence of "dU" "dT" SendString I obtain "U0" (10101010 00000000) and "T0" (00101010 00000000).
Received always perfectly with Hyperterm on the Port Com 8.
So the problem is not the component macros or the project but Pc App. The USB Serial driver work fine because HyperTerm work fine. It's between the COM Port data (RS232) OK when selected, and the USB Port data DP DM with lost data. PC App send not good the data when the USB Serial driver is selected.
I tried with the original Pc App 3 temps in the Flowcode example page. I have the same problem, when the string "temp1" is sent, UC receive only the last character of the string "1" with (00000000) at the end of received packet.
We will have probably the same problem in RX Data from USB port.
I hope this information can help the Matrix Staff to fix this problem.
To obtain the best result, I use now the Flowcode USB Serial driver .Inf, I inserted your VID and your PID in my USBSerialDriverDescriptor file. I will change it when we have fixed this problem.
Re: A simple com sender
Posted: Fri Sep 27, 2024 5:09 pm
by Nico595
Steve, I tried to use the COM1 on my Asus notebook, same problem with a small number of Com Port.
You can see the packet on "dT" SendString without the first string and "0" Dec at the end of the packet.

- Logic_Anayser_PcApp_Bug.jpg (66.3 KiB) Viewed 4443 times
Re: A simple com sender
Posted: Fri Sep 27, 2024 6:05 pm
by Steve-Matrix
So data is being sent by the PC Developer app, but it is not correct and the data received is incomplete or has errors.
There could be a mismatch with the baud rate, the parity or the start/stop bits on the sender and receiver side.
Re: A simple com sender
Posted: Fri Sep 27, 2024 10:19 pm
by Nico595
Perfectly exact Steve. The packet is only good when I use the Com Port 1 of the Shuttle because it's a integrated RS232. When I switch the Com Port in Pc App to the Com Port 8 (Flowcode USB Serial driver) data are lost.
I checked the setup of Com Port in the PC, I have default parameters of Windows with 115200 for the Baud rate.
So I have in the PC setup for Com Port 8:
Baud rate :115200
Data bits: 8
Parity : none
Stop bit : 1
Handshaking : none
I have the same setup in my USB Serial driver of the embedded device.
You can see on this screen, when I use HyperTerm on Com Port 8 of the same PC (Shuttle DS57U), all data are received good by the device. I wrote a small code to monitoring the USB receive buffer. When the device receive packets, this packets are resent by the device (on 10 Bytes with repeat).

- HyperTerm.jpg (75.09 KiB) Viewed 4403 times
In my code 100 Dec is ID for Vol and 84 Dec is the byte for Up, 85 Dec is the byte for Down.
During I answer you, I think, maybe the problem is the "0" sent with PC App at the end of the packet. I will add 1 byte in my buffer and I come back.
Re: A simple com sender
Posted: Fri Sep 27, 2024 11:22 pm
by Nico595
With a RX buffer of 3 Bytes I obtain "T" and "0" Dec
So the first string of SendString "dT" is not sent by PC App. My buffer save "0" Dec because the data of my RX buffer is "0" when I have no data. So the "0" data comes not from Pc App, it's just usbBuffer[1] without received data and usbBuffer[2] without received data.
I receive in the device :
usbBuffer[0] = "T"
usbBuffer[1] = "0" Buffer without data with reset
usbBuffer[2] = "0" Buffer without data with reset
I must receive :
usbBuffer[0] = "d"
usbBuffer[1] = "T"
usbBuffer[2} = "0" Buffer without data with reset
I receive good in the device with HyperTerm :
usbBuffer[0] = "d"
usbBuffer[1] = "T"
usbBuffer[2} = "0" Buffer without data with reset
I write "not sent by Pc App" because with HyperTerm, when I send 2 Bytes I receive good my 2 Bytes. But it's maybe a parameter of Flowcode PC App.
EDIT : I will sniff DM DP of the USB with the Logic Analyser tonight

Re: A simple com sender
Posted: Sat Sep 28, 2024 10:58 pm
by Nico595
I sniffed the USB hardware with success.
My first test was with HyperTerm, because we know HyperTerm send good the packet with 2 strings.
I can read my data "dU" in the pcap file in line 31712 of the USB data captured file.
Tomorrow, I will sniff the USB hardware with Flowcode Pc App. I designed a small App with 4 buttons. It's very easy

I will add captures and files tomorrow.
To sniff the USB hardware I used this method:
https://re-ws.pl/2022/08/sniffing-usb-t ... pcap-file/
Re: A simple com sender
Posted: Sun Sep 29, 2024 8:44 am
by Nico595
I compared the pcap file of HyperTerm and the pcap file of Flowcode Pc App.
We have 1 usb packet DATA "dU" with HyperTerm, work fine to receive data in the device.
We have 2 usb packets DATA with Flowcode Pc App, don't work to receive data in the device.
- The first usb packet DATA is ".dAT"
- The second usb packet DATA is "KU.."
You can see on this screen the usb packets with UART echo of usb RX with Flowcode Pc App.

- Logic_Analiser_usb_packet_FC10App_2.jpg (84.71 KiB) Viewed 4229 times
You can see the usb packet with HyperTerm to send string "dU".

- WireShark_Screen_HyperTerm_dU.jpg (106.64 KiB) Viewed 4227 times
Now you can see the usb packet with Flowcode Pc App to send string "dU". The first part of the string is here.

- WireShark_Screen_PcApp_d.jpg (105.63 KiB) Viewed 4221 times
Re: A simple com sender
Posted: Sun Sep 29, 2024 9:01 am
by Nico595
The second part of the string is here.

- WireShark_Screen_PcApp_U.jpg (106.43 KiB) Viewed 4219 times
I share you my Simple USB Sender Pc App :
Exported TXT files from DSLogic and WireShark PCAP files :
We can see with the first method, the DATA packet is sent on 40 bits and 5 Bytes are captured (HyperTerm and other Softawres).
With the second method, the DATA packet is sent on 32 bits and the string is cut in 2 parts (Flowcode Pc App).
I am not expert of usb encapsulation but this method don't work with my device. The first packet and all packets before the last string data are ignored. With the USB1 version 0x0100 Payload min is 8 Bytes however Data0 and Data1 are under 8 Bytes with Flowcode Pc App.
Re: A simple com sender
Posted: Sun Sep 29, 2024 1:43 pm
by Nico595
Now I try this :
SendString "ABCDEFG" with Flowcode PC App.
Flowcode Pc App send : DATA0 = "A" & DATA1 = "B" & DATA0 = "C" & DATA1 = "D" & DATA0 = "E" & DATA1 = "F" & DATA0 = "G"
Flowcode send 1 Byte per DATA usb packet.
I receive only the last string "G" and 0x00 usbBuffer[3].
SendString "ABCDEFG" with HyperTerm.
HyperTerm send : DATA1 = "ABCDEFG"
HyperTerm send 7 Bytes in one DATA usb packet.
I receive good only the first Bytes "ABC" because my array of usbBuffer is only [3].

- HyperTerm_usb_ABCDEFG.jpg (78.55 KiB) Viewed 4166 times
I think we have find the problem. Flowcode Pc App limit the DATA usb packet at 1 Byte. I think it's better use all capacity of DATA usb packet, for the speed and the bandwidth.
I can probably read the sent data in two time, or more. But it's not the best way, principally about the speed.
Please, can you fix it quickly ?
Re: A simple com sender
Posted: Mon Sep 30, 2024 10:38 am
by Nico595
I wrote the device receiver code for the two method, the first with more 1 Byte per DATA usb packet and the second with 1 Byte per DATA usb packet.
Now it work fine with HyperTerm and Flowcode Pc App but would be a good idea add parameter in Com Port Component : 1 Byte per DATA usb packet -> true / false. Of course if you can, maybe have you not access at this code if you use a GUI SCADA designer software.
The simple Pc App sender work fine, I will work on the Simple Pc App receiver ...
Have you other surprises like this ? ^^