Posted: 09:03am 25 Oct 2023 |
Copy link to clipboard |
Print this post |
|
Hi,
I am trying to send binary data via a COM port. The data contains zeros and it appears that the sending stops if a zero occurs in the data (because a zero does not make sense in a string?).
This is my example code, it sends position commands to a servo controller:
Option Base 0 Option Explicit Option Escape Option Default None
SetPin GP5, GP4, COM2 Open "COM2:57600" As #5 Pause 500 Print #5, "\&84\&01\&70\&2E" Print Lof(#5)
Pause 1000 Close #5
If the second byte (=the servo number) is not zero (e.g., \&01), it works: The respective servo moves; Lof(#5) = 252, indicating that the whole sequence was put into the out buffer.
If the second byte is zero (\&00), the servo does not move and Lof(#5) = 255, suggesting that the sequence was incomplete?
How do you send zero-containing binary data? I am sure, I am missing something. Any help is appreciated.
Best Thomas |