hello all
I'm sending some data via Serial from one arduino to another via RS485 Bus.
On the master I send a start byte using Serial.print(data[i],HEX);
where data[0] is the start byte.
On the slave side I'm expecting the data in something like
void receivedDataFromBus()
{
while(Serial.available() >= 5)
{
digitalWrite(controlBusDirection,HIGH);//Enable transmit mode on RS485
if(Serial.read() == 0x01)//Expect to receive the start Byte 0x01
{
for (uint8_t i = 1; i<= 4; i++) dataBusReceived[i] = Serial.read();//Store all remaining data in an array
Serial.print(checkCrc(dataBusReceived),HEX);//Calculate the correct CRC
delay(40);//Need to give time to empty the serial buffer
}
}
digitalWrite(controlBusDirection,LOW);//Disable transmit mode
}
My problem is the Serial.read reads in decimal format and then this if is never true.
I made some test and if I put were the correct conversion on decimal it works fine, but I prefer to use hex values.
How can I read it in hex format.
Is there any kind of Cast that I can use on Serial.read()?