n-wach / camino

A library for controlling an Arduino from Python over Serial
MIT License
16 stars 3 forks source link

Arduino Mega 2560 bad USARTN_RX_vect & USARTN_UDRE_vect defines. #1

Closed jorianxk closed 2 years ago

jorianxk commented 2 years ago

Hello,

While using this library in conjunction with an Arduino Mega 2560, the following warnings are given during compilation:

'USART_RX_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr] 'USART_UDRE_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr]

It seems that despite the comment on lines 29&30 of Camino.cpp, i.e.

29 #define USARTN_RX_vect USART_RX_vect // no number for some reason 30 #define USARTN_UDRE_vect USART_UDRE_vect // no number for some reason

The ATmega2560 does in fact use a numbering convention (source).

For the ATmega2560 Port 0 should be:

#define USARTN_RX_vect USART0_RX_vect // for some AT devices, there is no number. #define USARTN_UDRE_vect USART0_UDRE_vect // for some AT devices, there is no number.

Without this change obviously Atmega2560 won't respond to requests:

Callable added: num_calls
Callable added: get_nth_call
Got error on attempt 1/3: Nothing sent when a response was expected.
Got error on attempt 2/3: Nothing sent when a response was expected.
Got error on attempt 3/3: Nothing sent when a response was expected.
Traceback (most recent call last):
  File "/camino.py", line 100, in send_command
    response = self.read_packet()
  File "/camino.py", line 39, in read_packet
    header_byte_1 = self.read_byte()
  File "/camino.py", line 34, in read_byte
    raise CaminoException(
camino.CaminoException: Nothing sent when a response was expected.

Hope this helps!

n-wach commented 2 years ago

Thanks for looking into this!

You're right, ATmega2560 won't work with PORT=0. I think the current defines work for Arduino Uno(ATmega328P), and I forgot to check Mega.

I'm adding a check of ARDUINO_AVR_UNO flag to control the name.

Would appreciate it if you could test the changes in #2 (on Uno and Mega if possible) before I merge and release

jorianxk commented 2 years ago

Hello,

Worked for me with Arduino Mega 2560.

Thanks for the update!

Best,