telit / arduino-me310-library

code library for arduino projects using ME310G1 devices (for example on Charlie Board)
MIT License
9 stars 2 forks source link

Description of pins for UART #20

Open rkertesz opened 1 year ago

rkertesz commented 1 year ago

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

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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;