This code (written by @Blackfin) originally worked on a Mega2560, supporting both HW-Serial and SW-Serial. I have now migrated to a SAMD board using Zero bootloader.
The IDE 1.8.8 won't compile the code (Zero Native USB), I've tried commenting away everything that has to do with SW-serial and the code now compiles, but HW-Serial doesn't seem to start.. Earlier I could see all of the HEX values the board tried to transmit on HW-serial, printed on SerialUSB. Now I only get "Message timed out"
Somehow, I think the board interpret it doesn't have the HW-serial? hence doing nothing.
(This board doesn't have the EDBG/porgramming port)
Full code is attached, part that I think would be relevant are in this post.
Had the problems before I added up the Sercom handler, but that didn't solve my issue, however I would need it anyway.
which type of SAMD board? If I remember well, they not always have all the same naming convention of Serial stuff (Zero versus Feather M0). Long time I did not play with it though
Yes, I have checked and I think I have understood it but I can't be sure.
SerialUSB = Native USB port
Serial = D0/D1
As for now, I won't use the Serial on D0/1, I will use it later when I gotten this sketch to compile as it is.
I have with Sercom created/mapped Serial2 to pin 10(RX) and 11(TX), I can't say for sure this will work in my sketch yet.
The thing is, when I ran this sketch on the MEGA2560, the sketch printed on the monitor-Serial what it just transmitted on the "real" serial, even if the real serial was disconnected it tried to transmit. And the serial monitor showed
Tx Bufferz: 81 02 00 04 09 00 00 00 0D
As for now, the Zero seem to not initialize the HW-serial at all.
And the serial monitor just gives me
Message error.....: Message timeout
I just tried comment away the Sercom handler and assigning the Heatpump to "Serial" on 0/1, but I still get the "Message error.....: Message timeout" and nothing about what it's trying to transmit on the Serial.
The only difference is with 'Serial' it loops the message in infinity, with my Sercom, it only loops the message 6 times, then stops.
However, my problem isn't within the USB-Serial, it's the HW-serial that communicates with the Heat-pump that doesn't seem to initialize. Thats probably why it's not outputting what it's trying to transmit to the heatpump, on the SerialUSB(monitor) but instead throws error message on the monitor.
No real reason for the speed, the monitor is just used for debugging at this time.. The speed was enough on the Mega2560.
Tried you suggestion @J-M-L, still the same.
It's just like the compiler seeing Serial/Serial1/Serial2 (doesn't matter if I use Sercom or not) and interpreting is as it would not be a hardwareserial.
@Juraj, tried assigning it to Serial1 aswell, still doesn't seem to initialize HW-serial.
sx3000:
Tried you suggestion @J-M-L, still the same.
It's just like the compiler seeing Serial/Serial1/Serial2 (doesn't matter if I use Sercom or not) and interpreting is as it would not be a hardwareserial.
@Juraj, tried assigning it to Serial1 aswell, still doesn't seem to initialize HW-serial.
do you have the physical pin mapping and core board variant same as Zero?
Since the Heatpump wasn't connected, I got the 'Message timeout' after a second or two, and so it looped until I connected the heatpump.
But now, with Zero/SAMD it never plots the Tx buffer on the serial monitor. Doesn't matter if it's pluggen into heatpump or unplugged. Just throwing the Message timeout.
The problem should be withing the code, probably how the stream class is called/used.. I think..