-->
Page 3 of 4

Re: Serial byte output prints two bytes after it reaches 0x7

PostPosted: Wed Jan 04, 2017 11:40 am
by martinayotte
Looking at HardwareSerial.h, both/all are equivalent :
Code: Select all    size_t write(uint8_t) override;
    inline size_t write(unsigned long n)
    {
        return write((uint8_t) n);
    }
    inline size_t write(long n)
    {
        return write((uint8_t) n);
    }
    inline size_t write(unsigned int n)
    {
        return write((uint8_t) n);
    }
    inline size_t write(int n)
    {
        return write((uint8_t) n);
    }

Re: Serial byte output prints two bytes after it reaches 0x7

PostPosted: Wed Jan 04, 2017 12:06 pm
by SwiCago
Are you using HardwareSerial.h ? for your test? or regular built in Serial.begin
I am using Serial.begin and from what I read, it does not implement its write function as "(uint8_t) n"
I'll try HardwareSerial.h


martinayotte wrote:Looking at HardwareSerial.h, both/all are equivalent :
Code: Select all    size_t write(uint8_t) override;
    inline size_t write(unsigned long n)
    {
        return write((uint8_t) n);
    }
    inline size_t write(long n)
    {
        return write((uint8_t) n);
    }
    inline size_t write(unsigned int n)
    {
        return write((uint8_t) n);
    }
    inline size_t write(int n)
    {
        return write((uint8_t) n);
    }

Re: Serial byte output prints two bytes after it reaches 0x7

PostPosted: Wed Jan 04, 2017 12:52 pm
by martinayotte
HardwareSerial is the class name, and Serial is instantiated in HardwareSerial.cpp as :

Code: Select allHardwareSerial Serial(UART0);


So doing "Serial.begin()" is calling "HardwareSerial::begin()".

Re: Serial byte output prints two bytes after it reaches 0x7

PostPosted: Wed Jan 04, 2017 1:28 pm
by SwiCago
If it really is, then why does it not print 0x00 on the output?
You clearly posted that it's write method casts values (uint8_t) to, which should make it print 0x00, but in my dump it did not do that either. I find that strange.

In any case, thanks for the help so far, I'll see if I can figure it out. It has to be something stupid simple that I am missing

martinayotte wrote:HardwareSerial is the class name, and Serial is instantiated in HardwareSerial.cpp as :

Code: Select allHardwareSerial Serial(UART0);


So doing "Serial.begin()" is calling "HardwareSerial::begin()".