Closed 7aman closed 5 years ago
It's worth mentioning that only a turned off modem will cause this CPU usage. Disconnecting Rx and Tx have no effects on CPU. It's probably an issue of serialport
itself and not your module. This happens to data received by ttyS0
when I turn off modem. It goes on and on.
pi@monitor:~/gsm-v2 $ python3 -m serial.tools.miniterm /dev/ttyS0 115200
--- Miniterm on /dev/ttyS0 115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
at
OK
␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀
Hello there @7aman! Thanks for trying out serialport-gsm
!
Since the close
event is fired, it means the serialport
's close method
was fired successfully. I too think there is probably an issue with serialport
. I'll look into it and notify you if ever I happen to stumble with some workaround.
Nice thing your working out there with RPi 3 B and sim800L!
Thanks. I appreciate your consideration, and look forward to hearing from you.
I'm not sure if close
event is fired.
Text below, shows console's logs of my code (server.js
I shared above). When I was executing node server.js
Sim800L was running. After printing these messages I turned it off for 30 seconds. Then I turned it back on.
Since my simple console.log
callbacks on close
and error
events printed out nothing, it seems close
and error
events were not fired.
Also during these power-off and power-on actions, my code never exited and It kept running and functioning as nothing unusual happened.
pi@monitor:~/gsm-v2 $ node server.js
open msg: null
initialize msg: { status: 'success',
request: 'modemInitialized',
data: 'Modem Successfully Initialized' }
set pdu msg: { status: 'success', request: 'modemMode', data: 'PDU_Mode' }
@7aman any device disconnected while open or calling the close
method should fire the close
event. So turning off the Sim800L should fire close
event.
May I ask how you toggle power of your Sim800L?
@zabsalahid I do it by disconnecting VCC and GND.
Hi @7aman !
I have updated the module to 2.1.3
. Can you please update your module.
And see if it is still the same.
By disconnecting VCC and GND, you mean the Sim800L will have no power?
Can you also test if manually calling modem.close
would still have the same CPU usage and temp.
I tested v2.1.5. CPU usage is still going up.
I found a hardware solution but later I will try to fix this issue in my code.
Hardware Solution:
When sim800L is turned off, RPi3 is still listening and translating receiving bits. I have not any equipment (e.g. an oscilloscope) right now to check receiving bit. But if you open a serial console like I shared its results before, you will see some weird characters appear on serial console that shows RPi3 thinks it is receiving data.
After "OK" response, I turned off SIM800L.
pi@monitor:~/gsm-v2 $ python3 -m serial.tools.miniterm /dev/ttyS0 115200
--- Miniterm on /dev/ttyS0 115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
at
OK
␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀
After powering off, "␀" character will appear and it will fill rows and rows of terminal very fast. It is interesting that if you disconnect Rx from RPi3, terminal will stop showing "␀" character.
I temporarily fixed this issue by adding a middle hardware, a Bi-Directional Logic Level Converter. Its main application is to convert logic level between different devices such as Arduino that uses 5V and RPi3 which uses 3.3V. In this case because both SIM800L and RPi3 are using 3.3V it is not required. But by using this middle-man and applying 3.3V to both LV and HV sides, it will stop RPi3 to receive such wired bits at its serial port.
I will try later to remove logic converter and fix this issue in the code and let you know the result.
Thanks for your time.
By disconnecting VCC and GND, you mean the Sim800L will have no power?
Yes.
Story behind: I launched my little project over night to see if it is stable in long term. I launched a s-tui
in separate window and went to sleep. In the morning I found CPU usage was very high and temperature was up to 70 C degree. And SIM800L was not responding to abnormal sensors. I found power supply of SIM800L was disconnected at some point. I repeated disconnecting SIM800L power a few more times and found this issue.
Can you also test if manually calling
modem.close
would still have the same CPU usage and temp.
No. If I call modem.close()
manually in my code, it fires modem.on('close')
callback function and then closes and exits the process. So it will not use CPU anymore.
It is not helpful for me. I need an .on('disconnect')
event and a modem.reconnect()
to serve my purpose 24/7. I will try to implement such functionality later.
@7aman , I was using your sample code above and ran it. It works fine.
On close was called when I pulled out the wavecom fastrack
.
Also looked into @serialport/stream.js
, disconnecting a port will cause it to close the connection.
And this one using python. Immediately thrown an error upon disconnecting the device from the usb.
So it is an issue with RPi3 serial port (gpio 14, 15) or SIM800L.
Because you have not my set of hardware I will try to fix it and I will share the result with you.
Thanks for your time.
No problem @7aman.
Hello @7aman , How did you manage to implement .on('disconnect')
and also modem.reconnect()
? I also need those functionality. Because when I try to plug out my usb modem from my pc it calls the function modem.close()
and exits the process.
Hi.
Thanks for sharing your module. It is very helpful.
I set a RPi 3 B to monitoring some sensors. I use your module with a sim800L to provide a 24/7 SMS device to alert abnormal events. So my code must run 24/7.
This is a basic example that runs perfectly.
But when sim800L is turned off (it might happen sometimes), Rpi CPU usage and temperature will raise.
This is screenshot of
s-tui
on RPi.Console logs:
When sim800L is turned on back again, code will run perfectly again and CPU usage will drop to normal.
My question:
How can I handle this turned off situations?