Hi, I have successfully enabled the serialmodule in my meshtastic compile and hardcoded some of the settings in SerialModule.cpp --SerialModule::runOnce() as follows
radioConfig.preferences.serial_module_enabled = 1; radioConfig.preferences.serial_module_rxd = RXD2; radioConfig.preferences.serial_module_txd = TXD2; radioConfig.preferences.serial_module_timeout = 1000; radioConfig.preferences.serial_module_baud =RadioConfig_UserPreferences_Serial_Baud_BAUD_38400; radioConfig.preferences.serial_module_mode = RadioConfig_UserPreferences_Serial_Mode_MODE_Default; radioConfig.preferences.serial_module_echo = 0;
I have also changed the line
//SerialModuleRadio::SerialModuleRadio() : SinglePortModule(“SerialModuleRadio”, PortNum_SERIAL_APP){
to
SerialModuleRadio::SerialModuleRadio() : SinglePortModule(“SerialModuleRadio”, PortNum_TEXT_MESSAGE_APP){
I receive RS232 on pin IO34 and transmit on pin IO2 (These are fine on the board I am using.
When I enter the text ‘11111111111111111111’ in my serial terminal I can see it is correectly received as I added the line
DEBUG_MSG(“**************** {send2} Sending: %s %d %d\n”, p->decoded.payload.bytes, p->decoded.payload.size, p->which_payloadVariant);
to ErrorCode Router::send(MeshPacket *p) in Router.cpp just after the line p->from = getFrom(p);
The console shows
??:??:?? 2180 [SerialModule] **************** {send2} Sending: 11111111111111111111 20 4
modifying perhapsEncode to read
Routing_Error perhapsEncode(MeshPacket *p){
// If the packet is not yet encrypted, do so now
if (p->which_payloadVariant == MeshPacket_decoded_tag) {
static uint8_t bytes[MAX_RHPACKETLEN]; // we have to use a scratch buffer because a unionsize_t numbytes = pb_encode_to_bytes(bytes, sizeof(bytes), Data_fields, &p->decoded); DEBUG_MSG("{perhapsEncode} numbytes payload.bytes %d %s\n", numbytes, p->decoded.payload.bytes);
I get
??:??:?? 2180 [SerialModule] {perhapsEncode} numbytes payload.bytes 2 11111111111111111111
Here lies the problem Numbytes is only 2!
For the life of me I cannot see what is wrong and why numbytes is only 2.
My remote node wakes up but does not display anything.
At the very end of perhaps encode I added
DEBUG_MSG("{perhapsEncode} Encrypted text msg %s %d\n", p->encrypted.bytes, p->encrypted.size);
which returns > ??:??:?? 2180 [SerialModule] {perhapsEncode} Encrypted text msg ␟� 2
On a side note if I send a message using the android app from another node I see the same message come out of the serial port.
Please help. Thanks