Open smartroad opened 2 years ago
I can confirm, I have the same issue. My code:
from gsmHat import GSMHat, SMS, GPS
gsm = GSMHat('/dev/ttySC0', 115200)
while True:
if gsm.SMS_available() > 0:
newSMS = gsm.SMS_read()
print('Got new SMS from number %s' % newSMS.Sender)
print('It was received at %s' % newSMS.Date)
print('The message is: %s' % newSMS.Message)
Error code:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/dist-packages/gsmHat/gsmHat.py", line 616, in __workerThread
if self.__waitForUnlock():
File "/usr/local/lib/python3.9/dist-packages/gsmHat/gsmHat.py", line 478, in __waitForUnlock
raise 'Unhandled timeout during data reception'
TypeError: exceptions must derive from BaseException
I noticed that the module is crashing/switching off after this error.
I think, that I found solution. When looking on oscilloscope connected to 5v bus on RPI4 I saw large voltage variations. This probably caused thread error, and in my case self shutdown of SIM868 HAT. Looks like the problem is caused by insufficient power provided to the RPi. I resolved my problem by adding electrolytic capacitor across 5V/GND.
@flykarlos I faced same issue, can you confirm that the used of electrolytic capacitor prevent this error ?
I just had the library crash the thread when it received an SMS. here is the log:
looking at the script after sending the critical warning it basically causes the script to end using the
raise
command. Why does it do that? As soon as that happens the library stops working within my script and I don't get any sms messages being sent out or received. Is there a more graceful way to handle the error? Maybe making it wait a few seconds and then try again later?