tigrot Well-Known Member Licensed User Longtime User Feb 16, 2018 #1 Hi everybody I don't understand what is my mistake. I write to native serial port 1 on Arduino Mega 2560 by this code: Code: Copy strx=Array As Byte( "PE",13,10) Main.Serialnative1.WriteBytes(strx,0,4) strx=Array As Byte("RD 0", 13,10) Main.Serialnative1.WriteBytes(strx,0,6) Main.Serialnative1.Flush The result in hex code is Code: Copy 00 0d 0a 46 00 0d 0a 00 0d 0a ...F...... It doesn't resemble to anything, apart CR/LF. Probably the strings are not converted correctly in Array function? Thank you for help Regards Mauro Zanin
Hi everybody I don't understand what is my mistake. I write to native serial port 1 on Arduino Mega 2560 by this code: Code: Copy strx=Array As Byte( "PE",13,10) Main.Serialnative1.WriteBytes(strx,0,4) strx=Array As Byte("RD 0", 13,10) Main.Serialnative1.WriteBytes(strx,0,6) Main.Serialnative1.Flush The result in hex code is Code: Copy 00 0d 0a 46 00 0d 0a 00 0d 0a ...F...... It doesn't resemble to anything, apart CR/LF. Probably the strings are not converted correctly in Array function? Thank you for help Regards Mauro Zanin
tigrot Well-Known Member Licensed User Longtime User Feb 16, 2018 #2 Solved I had to redefine temporary arrays of bytes to strings: Code: Copy Dim stringx As String=JoinStrings(Array As String( "PE",CRLF)) Main.Serialnative1.WriteBytes(stringx,0,4) stringx=JoinStrings(Array As String("RD 0", CRLF)) Main.Serialnative1.WriteBytes(stringx,0,6) This works! Upvote 0
Solved I had to redefine temporary arrays of bytes to strings: Code: Copy Dim stringx As String=JoinStrings(Array As String( "PE",CRLF)) Main.Serialnative1.WriteBytes(stringx,0,4) stringx=JoinStrings(Array As String("RD 0", CRLF)) Main.Serialnative1.WriteBytes(stringx,0,6) This works!