Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description of pins for UART #20

Open
rkertesz opened this issue Apr 6, 2023 · 3 comments
Open

Description of pins for UART #20

rkertesz opened this issue Apr 6, 2023 · 3 comments

Comments

@rkertesz
Copy link

rkertesz commented Apr 6, 2023

There isn't a comment that describes this well enough or non-Charlie boards.
`/*

  • If a Telit-Board Charlie is not in use, the ME310 class needs the Uart Serial instance in the constructor, that will be used to communicate with the modem.\n
  • Please refer to your board configuration in variant.h file.
  • Example:
  • Uart Serial1(&sercom4, PIN_MODULE_RX, PIN_MODULE_TX, PAD_MODULE_RX, PAD_MODULE_TX, PIN_MODULE_RTS, PIN_MODULE_CTS);
  • ME310 myME310 (Serial1);
    */`

I assume that need to define these like so, but I'm a little confused.
#define PIN_MODULE_RX 0 #define PIN_MODULE_TX 1 #define PAD_MODULE_RX 2 #define PAD_MODULE_TX 3 #define PIN_MODULE_RTS 4 #define PIN_MODULE_CTS 5

What is PIN_MODULE_RX vs PAD_MODULE_RX for example?
If I have a generic arduino type device that has a hardware serial port (let's say arduino calls it "Serial") then what would need to be defined for the arduino board to talk to the device (like a Telit module like an ME910G1 on EVK2 or with a Telit Bravo board)?

@fabiopi-tlt
Copy link
Collaborator

for the Arduino MKRZero, for example:

https://github.com/arduino/ArduinoCore-samd/blob/master/variants/mkrzero/variant.h#L173
a Serial1 is already defined, and you should be already set using it with the ME310 constructor.
but for example if you want to use specific pins for the uart, you would have to create the Serial instance passing the pins, and as you have correctly guessed, PIN_MODULE_RX, PIN_MODULE_TX etc are placeholders in the descruption, so you should define them in order to match the hw pins of the board you want to use to communicate with the modem (and variant.h would define them if you want to use easy-to-remember names). For the Arduino Uno, using "Serial" might be difficult because it is also connected to the USB port used to flash the board. A device with at least 2 hw UARTs (such as the SAM21 based ones), or a software serial with a lower baud rate might be used.

@rkertesz
Copy link
Author

rkertesz commented Apr 8, 2023

Thanks. I'm working with an Adafruit Clue, which uses an nrf52840 and does have a hardware Serial1 available as defined in this Uart.h file.

I am getting an error in ME310.cpp on a few lines like this:
lib\ME310\src\ME310.cpp:7829:30: error: 'class Uart' has no member named 'getTimeout'; did you mean 'setTimeout'? timeout+=mSerial.getTimeout(); ^~~~~~~~~~ setTimeout

It looks like we are trying to see if the UART needs to stop listening because we waited longer than allowed but, indeed, when I go digging in the UART definition I'm not able to find anything about getTimeout. I'm not sure if that is specific to how it is implemented for the nrf52840 or not.

If I comment out the 4 lines with getTimeout in ME310.cpp then the compilation completes but I'm sure that this is critical to operation. Can you shed some light on how to address this error?

@fabiopi-tlt
Copy link
Collaborator

In theory, getTimeout() is an inherited method from Stream class: https://github.com/arduino/ArduinoCore-API/blob/master/api/Stream.h#L69

but the Adafruit Clue seems to be missing it: https://github.com/adafruit/Adafruit_nRF52_Arduino/blob/211566bc25a0ea0f7d6b1847e615ac242597ae2b/cores/nRF5/Stream.h#L68

I think the easiest way would be to add the method to the Stream.h

_unsigned long getTimeout(void) { return timeout; }

or, since we are using the default timeout of Stream class (1 second) because nothing is calling setTimeout, as far as I can see, you could simply replace
timeout+=mSerial.getTimeout();
with
timeout+=1000;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants