"Serial1.on('data', function (data) {......" not works for me, is works for any other ?? #6057
Replies: 1 comment
-
Posted at 2018-09-15 by @MaBecker This is what I tested: connect to device with WEB IDE via TCP/IP upload this code for a ESP8266 12F
send data over serial with result every send toggle the onboard led Hope this works for you too. Posted at 2018-09-15 by user94070 Thanks for response ... I'll try and reply soon Posted at 2018-09-15 by user94070 Hi @MaBecker Posted at 2018-09-15 by @MaBecker This is the setup I used to test
Question: Does WEB IDE over serial and TCP/IP work for you? Posted at 2018-09-16 by user94070 Yes, serial and WEB TCP/IP both are working fine to upload code. And one more thing I'm using NodeMCU, which runs on the ESP8266. My Thinking about this issue: Please provide me your exact firmware. (if possible) becaue I'm using 4mb version that may be differ from yours. Posted at 2018-09-16 by @MaBecker
Espruino branch: master
try this snippet too:
Posted at 2018-09-16 by @MaBecker please post output of process.env Posted at 2018-09-16 by user94070 Thanks for you response
and nothing happen in console when I typed and uploaded code which is provided by you. TTL 5V-----------------------------------NodeMCU 5V (VCC IN) I found somewhere that NodeMCU works without level shifting on RX/TX. So, I tried without level shifter with another NodeMCU and 2 TTL Posted at 2018-09-16 by @MaBecker This is what I use: USB to TTL Serial Cable 3,3V and a D-duino ESP8266 12F device. Attachments: Posted at 2018-09-16 by @allObjects ...on a beech hardwood floor/table... makes me homesick in a good way... so, more precise: recalls lovely memories. Posted at 2018-09-16 by user94070 Great ... I think, I should try some other board or standalone ESP8266 first...Thanks for all your response but if you found any other information about this please share....thanks-a-lot :) Posted at 2018-09-16 by user94070 And since it is not solved so I'm not closing this convo, may be someone else may help Thanks @MaBecker Posted at 2018-10-24 by maman Hello @MaBecker, I have tested your code on Wemos D1 Mini (ESP8266, ESP-12) using Espruino 2.00,
Serial3 is assigned as software serial. However, if we increase the baudrate to 115200, software-serial will get the wrong data. Thanks @MaBecker Posted at 2018-10-24 by @MaBecker Are you using the latest travis build? Posted at 2018-10-24 by maman yes. Yesterday, I updated the source. We also tested for sending data from ESP to PC, we found that the PC get the wrong data, at any baudrate. So, for receiving, the software serial is ok for up to 9600, while for sending data is failed. My code is tested on hardware serial (Serial1), it is no problem for sending or receiving. Posted at 2018-10-24 by @MaBecker Ok, Check the serial snippet in espruino/Espruino#1511 Posted at 2018-10-24 by maman Sorry, just now, I updated the espruino code to the latest one.
However, if we increase the baud-rate to 115200, the ESP will be crashed. Thanks for your help, @MaBecker Posted at 2018-10-24 by @MaBecker Ok, what kind of dispay? Posted at 2018-10-24 by maman LED matrix display (P10), the size is about 1m x 6m Posted at 2018-10-24 by @MaBecker Do you like to Share a link or picture? Posted at 2018-10-25 by maman Sure, Like this one : Posted at 2018-10-25 by @gfwilliams
Software serial can't handle much above 9600 baud, so this is to be expected. If you want higher then you could use an external SPI to serial bridge chip. Posted at 2018-10-25 by @MaBecker @maman Nice, did you buy one? I have a 32x32 neopixel display build of 16 times 8x8 Posted at 2018-10-28 by maman Hello @MaBecker, Now, I am trying to use software serial to communicate with MODBUS energy meter. The software serial can send the command to the meter, however, get error data from the meter. If I change to use hardware serial, using the same code, the ESP can receive data, properly. The error data is consistent. The first byte is should be 0x01 (00000001), but we get 0x80 Is there any hint to correct the bytes ? Thanks, Posted at 2018-10-28 by @MaBecker Please share your Posted at 2018-10-28 by maman var MAX485_DE = D12; Posted at 2018-10-28 by @MaBecker Yes can confirm this, please check espruino/Espruino#1510 You are welcome to fix this ;-) Attachments: Posted at 2018-10-29 by Frida @MaBecker,
'#if defined(ESP8266) Posted at 2018-10-29 by @MaBecker Wow nice work around - Thanks for sharing @frida Hmm cause reboot for ESP8266_BOARD and ESP8266_4MB with Espruino 2v00.27
Posted at 2018-10-31 by Frida Hello @MaBecker, PS. jeg har kun en ESP8266-01 med 512KB. Posted at 2018-10-31 by @MaBecker So after we start to understand why this causes a Posted at 2018-11-11 by Frida Some tests:
By default setup, PB0, PB1 and PB2 are not touched.
With this setup, PB0, PB1 and PB2 are overwritten.
In the file 'jsserial.c' and in the function 'jsserialPopulateUSARTInfo' there are:
I do not know what it's doing, but it returns 4 bytes for 'bytesize' and 'stopbits', like 32 bits, but in 'JshUSARTInfo' they are set up as 'chars' That is, 'bytesize' overwrites 'parity, stopbits and xOnXOff'. It's worse with 'stopbits' because it will overwrite 'xOnXOff' and 'errorHandling' as well as write in an illegal address. Maybe we could get a 'JSV_CHAR' to these two. If I'm taking a'PICO 'and using:
There's nothing going on.
Which shows that stopbits are overwritten by 0. Hope it is understandable. Posted at 2018-11-12 by Frida Posted at 2018-11-12 by @MaBecker @frida: Thanks for testing and sharing your results I try to catch up:
List of addresses of JshUSARTInfo
Now I am testing with some if defs in src/jsutils.h
@gfwilliams is this how you would thought to use and use this flag for jshUSARTSetup
Posted at 2018-11-12 by Frida It is not only 'ESP8266', 'PICO' also has problems. Posted at 2018-11-12 by @MaBecker Ouch, so let me double check with my pico and than extend this issue with the label "pico board" Posted at 2018-11-12 by @gfwilliams Wow, ok - sorry everyone (especially @MaBecker for thinking this was just ESP8266 specific). Thanks @frida for pointing this out - it's the I'll commit a fix for this in the next hour or so - and I'll check out the other config object uses in case there are other similar issues elsewhere. Posted at 2018-11-12 by Frida Donated 100,00 USD to Posted at 2018-11-12 by @gfwilliams Wow, thank you - that's awesome! Especially given your previous donations as well! Thanks for everyone's help in tracking this down too. It's one of those nice cases where having Espruino on more platforms means more bugs get found and it gets more reliable for everyone. Just FYI, the bug/fix is on espruino/Espruino#1510 - in the end I went with just changing the call to As you suggested, Posted at 2018-11-12 by @MaBecker Well Gordon, next time I fetch my Espruino boards for testing as well :) Just tested the fix, works great, thanks lot for that quick fix! Do you have plans to handle parity ? Posted at 2018-11-12 by @gfwilliams
I do at some point, but honestly that's probably just 'when I need it'. If you want it, I'dd to a pull request. At least on sending it's just one extra bit that's pretty easy to calculate. Posted at 2018-11-12 by @MaBecker Not need on my side, will ask again if I needed |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-09-15 by user94070
# This code is not working for me. I tried below code...and tried many ways but not receiving on RX but TX works fine.
on Espruino v1.99 on NodeMCU
var status=0;
function swap() {
status = !status;
digitalWrite(NodeMCU.D0, status);
}
function onInit()
{
Serial1.setup(9600);
Serial1.on('data', function (data) { swap(); });
LoopbackA.setConsole();
}
//onInit();
Beta Was this translation helpful? Give feedback.
All reactions