Go Down

Topic: What is used instead of BYTE? (Read 1 time) previous topic - next topic

impellbm

Error is "The BYTE keyword is no longer supported"



Quote

#include <SoftwareSerial.h>
#define rxPin 2
#define txPin 3

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);
void setup() {
  Serial.begin(9600);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  
  mySerial.begin(9600);
}
void loop(){
  mySerial.print(0, BYTE);
  Serial.print("HELLO");
  
  delay(100);
}





PaulS

Code: [Select]
  mySerial.print(0, BYTE);
==>
Code: [Select]
mySerial.write((byte)0);
as has been posted MANY times.

impellbm

thanks how do i search for things like that? I have looked for it a lot.

GoForSmoke

Here's AVR Libc Modules with a lot of particulars:
http://www.nongnu.org/avr-libc/user-manual/modules.html

That's on the home site for the C++ Arduino uses.
I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

impellbm

in my code above how do i replace the "Hello" with the actual serial string the sabertooth is seeing? so i can debug with my monitor?

Nick Gammon


thanks how do i search for things like that? I have looked for it a lot.


You could try Googling:

Code: [Select]
"The BYTE keyword is no longer supported" +arduino

Second hit led to: http://wyolum.com/?p=624

On that page:

Quote
Upgrading to Arduino 1.0

ISSUE #1: "BYTE" keyword is no longer supported ...

GoForSmoke


in my code above how do i replace the "Hello" with the actual serial string the sabertooth is seeing? so i can debug with my monitor?


You make a byte array to hold the incoming characters and then in loop() you watch for then serial data, get it (I find it best to get 1 character at a time, you may loop() many times between characters arriving. There's time to do other things between if you want/need.) and add it to the byte array (I use a byte variable to know what array index to fill next, starts with 0, and increment that each time I add a new character.) and when it's done (Aha! How to know when? Hang on!) add a 0 byte to terminate the string in the byte array. The byte array then holds the string to print.

------------------------------------------
How to know when to end the word or line? Lots of ways for lots of needs.

Worst case for end of line is if too much time has passed since the last character arrived then the line must be finished. That's terrible code though and really asking for trouble but hey you might get away with it for a long time. I actually did use that in code to read electric meter output but there are so many error checks on the data that I catch and handle errors... by dumping the data message as bad and getting the next one.

In Serial Monitor I set it up so that each line sent gets a carriage return added but you can go with new line, carriage return, both or the default which is nothing. It gives me an end stop.

If I expect multiple data items sent then I separate them with delimiters like space, comma, semi-colon, etc, and watch for those in my code... the delimiter is my end of word marker. Using different markers can give you extra error checking since serial transmission is not guaranteed.

When you see strings as arrays and serial data as 1 byte telegrams, simple approaches should become clear to you. Can you compare two strings in two arrays without using strcmp()? Certainly! The same way that strcmp() does! If the bytes at each array position are the same until both are zero (end of a C string is always 0) then the strings are equal. And look Ma, no library!
I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Go Up