Serial Communication

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
ToughCookie
Normal user
Posts: 10
Joined: 03 Jul 2021, 10:22

Serial Communication

#1 Post by ToughCookie » 01 Aug 2021, 13:43

Hello everyone!
I have air monitoring device, I want to to read data from it via network, but device has only Serial port interface.

To start recieve data procedure I need send 13 bytes to the device

Code: Select all

0x55 0xCD 0x47 0x00 x00 0x00 0x00 0x00 0x00 0x01 0x69 0x0D 0x0A
and then device will response with 40 bytes data

Code: Select all

0xAA 0x00 0x13 0x00 0x14 0x00 0x0A 0x00 0xA0 0x02 0x00 0x0B 0x72 0x14 0xDC 0x01 0x04 0x00 0x00 0x08 0xAC 0x02 0x73 0x00 0x70 0x00 0x04 0x00 0x02 0x00 0x02 0x00 0x00 0x00 0x00 0x47 0x04 0xD7 0x0D 0x0A
Can I send HEX data via serial port?
How can I recieve response data?

PS. I tried to use Ser2Net plugin to see if it would be useful in my case, but I had diffucults.
I could sent data from network and recieve it in Serial port, but I couldn't do the same in vice versa.
Capture.PNG
Capture.PNG (20.08 KiB) Viewed 4634 times

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Communication

#2 Post by TD-er » 01 Aug 2021, 13:50

I can see why the other way around is difficult as there is no clear "end of message".

Not sure how it can be fixed without code change in the plugin.

Also the SerialProxy plugin isn't usable here as it doesn't allow to translate binary data to/from HEX.

ToughCookie
Normal user
Posts: 10
Joined: 03 Jul 2021, 10:22

Re: Serial Communication

#3 Post by ToughCookie » 01 Aug 2021, 14:25

Hi!
I just tried to send data between TCP(Laptop) <->ESPEasy unit <->Serial port(Laptop), but something goes wrong.
When I sending data via Serial monitor "Both NL & CR" symbols are sent in the end of message, so it defenetly has end of the message.
Why I can't see any massages in Putty window? What I missed?

ToughCookie
Normal user
Posts: 10
Joined: 03 Jul 2021, 10:22

Re: Serial Communication

#4 Post by ToughCookie » 03 Aug 2021, 20:39

I found out that plugin has command to send message back to client ser2netclientsend,"Message"
Maybe it's the one of the steps to solve my problem, but unfortunately I can't catch Serial EVENT to recieve data back to client, or do something else.

Tried to set many different options in Ser2Net Plugin
Capture.PNG
Capture.PNG (33.35 KiB) Viewed 4561 times
Tried to send data though network port and quickly (before RX Receive Timeout would expire) sendback data via Serial Monitor (UART), but no bata get back to network port.
Tried to turn OFF Serial port in the unit settings and use Ser2Net only, but it didn't help.
Tried to use second HW Uart, but it didn't help too.


But some circumstances gave me opportunity to view Serial EVENT :o

Code: Select all

923178: EVENT: TaskInit#Ser2Net=1,1
923236: RuleDebug: 011: !serial do
923238: RuleDebug: 010: logentry,'seeeeerial'
923239: EVENT: TaskInit#Ser2Net=1,1 Processing time:61 milliSeconds
928417: sendcontent free: 20824 chunk size:398
928421: sendcontent free: 20208 chunk size:292
928422: sendcontent free: 19536 chunk size:0
933604: sendcontent free: 20368 chunk size:0
933653: EVENT: !Serial#
933656: RuleDebug: 001: !serial do
933658: RuleDebug: 000: logentry,'seeeeerial'
933658: ACT : LogEntry,'SEEEEERIAL'
933660: Command: LogEntry
933660: LogEntry,'SEEEEERIAL'
933660: Par1: 1162167552 Par2: 0 Par3: 0 Par4: 0 Par5: 0
933661: SEEEEERIAL
933662: EVENT: !Serial#
Capture2.PNG
Capture2.PNG (4.55 KiB) Viewed 4561 times
During all this time I got two Serial EVENTS and I don't know how to reproduce it.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial Communication

#5 Post by TD-er » 03 Aug 2021, 21:29

Code: Select all

on ... do

endon
You're missing the "do"
Also I'm not 100% sure the "!serial" event will be triggered.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 29 guests