Most recent activity
-
I am using two soft serials, taking input from one UART and passing it to the USB UART.
var hubSerial = new Serial(); hubSerial.setup(2400, { // problematic when baud rate=9600 rx: NodeMCU.D5, tx: NodeMCU.D6 }); var usbSerial = new Serial(); usbSerial.setup(9600, { rx: NodeMCU.D9, tx: NodeMCU.D10 }); usbSerial.on('data', function (data) { try { hubSerial.print(data); } catch (e) { d0("failed to send on hub's data"); } }); hubSerial.on('data', function (data) { try { usbSerial.print(data); } catch (e) { d0("failed to send on usb's data"); } });
d0() is essentially console.log over port 23.
The PIN assignment cannot be changed hence the use of soft serial. I think the issue is that .on('data',..) is coming back 1 or 2 bytes at a time. I will experiment using .available().
-
From http://www.espruino.com/USART
"As software serial doesn't use dedicated hardware there are some compromises:
Baud rates significantly above 9600 baud are unlikely to be reliable
Sending more than one or two characters will block execution of other JavaScript code until completion (hardware serial ports have a ~100 byte transmit buffer)
Software serial reception will become increasingly unreliable the higher the CPU load."In my application, I use soft serial (rx=D5, tx=D6). I get bursts of 60+ bytes (5x a second) from an external source. I find that anything beyond 2400 baud increases errors in the data received. What's the experience of others?
Using an Amica 8266 board.
-
- 1 comment
- 407 views
-
-
- 6 comments
- 634 views
-
-
Your first line (D25,D26) produces result but not (D26,D26)!
var cmds = { // main menu top left - select mainSelect: [ 9.0, 4.4, 0.6, 0.5, 0.6, 1.6, 0.6, 1.6, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 1.6, 0.6, 1.6, 0.6, 0.5, 0.6, 1.6, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 0.5, 0.6, 1.6, 0.6, 0.5, 0.6, 1.6, 0.6, 0.5, 0.6, 1.6, 0.6, 1.6, 0.6, 1.6, 0.6, 1.6, 0.6, 0.5, 0.6, 1.6, 0.6, 0.5, 0.6, 1.6, 0.6, 42.9, 9.0, 2.2, 0.6, 95.9, 9.0, 2.2, 0.6, 95.9, 9.0, 2.2, 0.6, 95.9, 9.0, 2.2, 0.6, 95.9, 9.0, 2.2, 0.6, 95.9, 9.0, 2.2, 0.6, 95.9, 9.0, 2.2, 0.6, 95.9, 9.0, 2.2, 0.6 ]}; /* received on the other end (D25,D26): 4.4,0.5,0.6,0.5,1.6,0.5,1.6,0.6,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.6,1.6,0.6,1.6,0.6,0.5,0.6,1.6,0.6,0.5,0.6,0.5,0.6,0.5,0.6,0.5,0.6,0.5,0.6,0.5,0.6,0.5,0.6,0.5,0.6,0.5,0.5,1.6,0.6,0.5,0.6,1.6,0.6,0.5,0.6,1.6,0.5,1.6,0.6,1.6,0.6,1.6,0.5,0.5,0.6,1.6,0.6,0.5,0.6,1.6,0.6,42.9,8.9,2.3,0.5,95.9,8.9,2.3,0.5,95.9,8.9,2.2,0.7,95.9,8.9,2.2,0.7,95.9,8.9,2.2,0.6,95.9,9.0,2.2,0.6,95.9,9.0,2.2,0.6,95.9,8.9,2.2 0.2 */
I guess I will use D25,26 for transmission.
A query: not sure why the first value is consistently missing (i.e. 9.0).
Am I in fact transmitting the inverse pattern or am I just not understanding the IR protocol? (The definition file was captured (transmitted from a physical remote) using the same Receiver code, i.e. (from you!)
function onInit() { digitalWrite(D2, 0); pinMode(D1, "input_pullup"); var d = []; setWatch(function (e) { d.push(1000 * (e.time - e.lastTime)); }, D1, { edge: "both", repeat: true }); var lastLen = 0; setInterval(function () { if (d.length && d.length == lastLen) { d.shift(); // remove first element console.log(d.map(a => a.toFixed(1)).toString()); d = []; } lastLen = d.length; }, 200); setInterval(() => LED3.toggle(), 500); }
-
Thanks - I am using v2.05 firmware (Sep 2019 vintage PuckJS). The onboard IR LED transmits in the ~940nm (same as mine) so it's odd that the same receiver does not see it.
I have now inverted the roles of the two PuckJS. Again the same phenomenon (second Puck sees the IR signal from my own LED but not Puck's). It is unlikely that the transmitter on both Pucks are faulty. But I don't have anything else to test them with. Any idea?
Using hubSerial.available() - rather than hubSerial.data('on') - to chunk the input stream seems to make some difference (fewer errors) at 4800 baud. But no difference at 2400 (mostly good) or 9600 (bad transmission). See code below (both .available and .on('data') fragments are included: