RealTadango / FrSky

My S.Port sensors and OpenTX Lua scripts
78 stars 28 forks source link

Add explanation to readme about how to use the hardward serial. #19

Open RobinLeblond opened 2 years ago

RobinLeblond commented 2 years ago

Hello, I didn't know how to ask this elsaway, but can you explain how to use it with the hardware serial instead of the sofware one ? All your example look like using the software serial, thanks.

RealTadango commented 2 years ago

Better documentation is a good idea 😊

You can use hardware serial like this:

SPortHub hub(0x12, Serial);

RobinLeblond commented 2 years ago

Wow, easy like that! Thanks

icebreaker-ch commented 10 months ago

Unfortunately, this solution does not work due to several reasons:

1) The constructor of SPortHub with a Serial parameter is hidden in a strange conditional compilation statement:

 #ifdef Serial_
            SPortHub(int physicalId, Serial_& serial);
    #elif HardwareSerial
            SPortHub(int physicalId, HardwareSerial& serial);
    #endif

I think, the different constructors shall be all visible and overloaded.

2) Because of the conversion operator Serial_::operator bool() in the class Serial_ the constructor used for SPortHub(0x12, Serial); is again; SPortHub(int physicalId, int softwarePin); which makes no sense at all, but we get no error message here.