I am attempting to read bytes sent from Arduino Uno using Serial.Write (Documents say this sends data as binary)
I have confirmed via Realterm that each byte is sent as 1 8bit binary group (0 to 255 = 00000000 to 11111111)
In the Serial DataAvailable event I have
Dim m As MemoryBlock = frmMain.Serial1.ReadAll(Encodings.WindowsANSI)
frmMain.txtIncoming.Text = frmMain.txtIncoming.Text + str(m.byte(0))
This gives me 0-63 but then restarts at 0. I have confirmed (via Realterm) that the arduino sketch is indeed sending all bytes from 0-255 and viewing the memoryblock in xojo debug confirms there is only one byte…
So what am I missing? Obviously there is something I don’t understand.
I have tried multiple ‘Encodings’ to no avail.
I believe that the default protocol settings are 7N1. Make sure you’re setting the Serial protocol to Bits=8, Parity=0, StopBits=1. Otherwise, the 8th bit of each byte is dropped and used as the parity bit.
Or, UUENCODE or BASE64ENCODE the binary so that it is compatible with 7E1 or 7O1 transmission.
I never thought that I’d need THAT particular knowledge ever again :S
Ya, the data spits out fine using Realterm console… (connecting via usb which converts to com port) I get the full range of 0-255 monitoring with binary or hex.
Watching the memoryblock it gets to 3F and then starts over
Edit:
What I need is to be able to receive all bytes 0-255
Here is the Arduino Test Code if you are interested…
byte mybyte = 0;
byte trash;
void setup() {
// start serial port at 115200 bps default 8-n-1
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
delay(3000);
//clear serial
while (Serial.available() > 0) {
trash = Serial.read();
}
}
void loop() {
//send byte
Serial.write(mybyte);
//increment counter
if (mybyte == 255) {
mybyte = 0;
}else{
mybyte++;
}
//wait 1s
delay(1000);
}
Ah - I misunderstood what you were trying to accomplish - it’s not the value of the bytes, but the number of them in the loop. Is that correct? So what you are doing is trying to send byte values 0 to 255 over the link In a loop?
Thanks for your initial post Tim, I went back to ensure that I was Indeed setting the serial port correctly. I disabled MY dropdowns that allowed the user to set the port settings, and commented them out.
I set the port manually via the xojo IDE and it “magically” started working correctly.
Obviously I have something messed up with my listindex properties …