Dear all,
I would like to thank you for the discussion giving many useful hints and tips.
Finally I found out what was preventing my Inkey - loop from receiving the first bytes of the replied message:
[code:1:8043265eb2]Dim Tx_buf(128) As Byte
Dim Command As String * 127 At Tx_buf Overlay
Input "Command: " , Command 'command via terminal
Command = Command + Chr(13) 'append CR
X = len(command)
Printbin #1 , Tx_buf(1) , X 'output x command bytes[/code:1:8043265eb2]
This goes back to one of the questions from MWS - yes I know the difference between print and printbin.
As you can see I use the overlay of the string variable "Command" on a Byte Array " Tx_buf".
So I can send easily Bytes that represent the characters of a string in ASCII.
I like this method. :)
Finally I need to add a <CR> at the end, because this is required from my device I want to communicate with.
So the only explanation I have is that this code above does not exactly do what I want it to do in the sense that it takes longer than expected before my receiving loop can start. So as a consequence I miss the first ca. 10 Bytes when receiving the reply to the command.
Also I got the impression that too many bytes are sent - my device returns then " bad command" .
What I now did and what actually solved my problem was to use as advised the statement <print #1 , Command ; Chr(13) ;> and it works fine! :D
Thanks again!
Cheers,
Johannes
↧