Read uint8 from serial

I’m working with this library and I need to be able to send/receive unsigned bytes. I can send them with Serial1.write but I’m unable to read them. I’ve tried looping with Serial1.read, casting with Serial1.readBytes and basically every possible way to read the serial I can think of but all I’m getting is garbage. Is there any native way to read to an unsigned char buffer on the elctron?

@jcole, do you have a link to the actual code?

I don’t quite see this issue

I’ve tried to write and read bytes with this code and a TX-RX loopback and it works as expected

uint8_t buf[256];
uint8_t inbuf[256];

void setup() 
{
  Serial.begin(115200);
  Serial1.begin(9600);

  for (uint8_t i=0; i<30;i++)
    buf[i] = i;
}

void loop() 
{
  Serial1.write(buf, 30);
  delay(100);
  Serial1.readBytes((char*)inbuf, 255);
    
  for(int i=0; i<30; i++)
  {
    delay(5);
    Serial.printf("0x%02x ", inbuf[i]);
  }
  Serial.println();
}

The thing to take into account is the 64byte RX/TX buffer tho’ (observer the “missing” 0x3f entry in each block)

http://docs.link-labs.com/m/52162/l/481048?data-resolve-url=true&data-manual-id=52162

Yeah, I don’t know. I went from getting garbage to getting no response at all. I just contacted the link labs people so hopefully they can shed some light.