vaj4088:
There are several different Software Serial interfaces, each with its own limitations. You did not say which one you have, and you did not show your code.
i didn't know there were several different SoftwareSerial libraries. The one I have has the following
SoftwareSerial.cpp (formerly NewSoftSerial.cpp)
vaj4088:
The Software Serial that I am most familiar with will only listen on one port at a time, yet I have used this to link hundreds of Unos. Each Uno had one hardware serial port for debugging, and two software serial ports to link to adjacent Unos.
Here's a Two Port Receive example which I assume works, but does very little, and which I inferred implies that multiple ports can be used simultaneously[/quote]
vaj4088:
Were you attempting to exceed the limitations of your implementation?
i certainly wasn't attempt to exceed the limitations. My understanding is the limitation is 57600 bps and RX pins are restricted to RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
simplified code that works inside #if/#else
// NCE USB Cab Interface
const char *version = "CabUsb 200522b";
#include "CabUsb.h"
#include "cabbus.h"
#include "jmriIf.h"
#if defined __AVR_ATmega328P__ // Uno
SoftwareSerial Serial1 (RX1, TX1);
SoftwareSerial Serial3 (RX3, TX3);
#endif
extern void pcRead (void);
#if 0
unsigned int debug = 0;
#elif 0
unsigned int debug = DBG_BUS_RESP;
#else
unsigned int debug = DBG_BUS_RESP| DBG_JMRI_MON;
#endif
// ---------------------------------------------------------
byte ioPins [] = {Hb, TxEn1, TxEn3 };
#define NumIoPins sizeof(ioPins)
// -----------------------------------------------------------------------------
void
loop (void)
{
#if defined __AVR_ATmega328P__ // Uno
Serial1.listen ();
if (Serial1.available()) {
uint8_t c = Serial1.read ();
Serial.println (c, HEX);
}
#else
jmriIf ();
busProcess ();
pcRead ();
#endif
}
// ---------------------------------------------------------
void
setup (void)
{
char s [40];
Serial.begin (115200);
Serial1.begin(9600);
if (! Serial1)
Serial.println ("Serial1 begin failed");
else {
sprintf (s, "%s: RX1 %d, TX1 %d", __func__, RX1, TX1);
Serial.println (s);
}
Serial3.begin(9600);
if (! Serial3)
Serial.println ("Serial3 begin failed");
else {
sprintf (s, "%s: RX3 %d, TX3 %d", __func__, RX3, TX3);
Serial.println (s);
}
for (uint8_t i= 0; i < NumIoPins; i++) {
pinMode (ioPins [i], OUTPUT);
digitalWrite (ioPins [i], LOW); // disable TX
}
Serial.println (version);
#if defined __AVR_ATmega328P__ // Uno
Serial.println ("Uno");
#endif
#if defined __AVR_ATmega2560__
Serial.println ("Mega");
#endif
}
cabbus.cpp (6.63 KB)
cabbus.h (226 Bytes)
CabUsb.h (605 Bytes)
jmriIf.cpp (4.29 KB)
jmriIf.h (215 Bytes)
keycodes.h (4.77 KB)
pcRead.cpp (4.33 KB)