GithubHelp home page GithubHelp logo

Comments (12)

zabsalahid avatar zabsalahid commented on August 23, 2024 1

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!

from serialport-gsm.

zabsalahid avatar zabsalahid commented on August 23, 2024 1

@7aman , I was using your sample code above and ran it. It works fine.
image
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.
image
Immediately thrown an error upon disconnecting the device from the usb.

from serialport-gsm.

zabsalahid avatar zabsalahid commented on August 23, 2024 1

No problem @7aman.

from serialport-gsm.

7aman avatar 7aman commented on August 23, 2024

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
␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀␀

from serialport-gsm.

7aman avatar 7aman commented on August 23, 2024

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' }

from serialport-gsm.

zabsalahid avatar zabsalahid commented on August 23, 2024

@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?

from serialport-gsm.

7aman avatar 7aman commented on August 23, 2024

@zabsalahid I do it by disconnecting VCC and GND.

from serialport-gsm.

zabsalahid avatar zabsalahid commented on August 23, 2024

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.

from serialport-gsm.

7aman avatar 7aman commented on August 23, 2024

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.

from serialport-gsm.

7aman avatar 7aman commented on August 23, 2024

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.

from serialport-gsm.

7aman avatar 7aman commented on August 23, 2024

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.

from serialport-gsm.

iamqinglong avatar iamqinglong commented on August 23, 2024

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.

from serialport-gsm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.