Bhargav Lalaji
asked on
how can read message, how can I decode my recieved message?
Hi there,
I am try to learning a home automation system on Raspberry pi through GSM, but unfortunetally I am getting error in my python coding.
The Problem is When I want to print my received message that time I am getting this kind of response b'b\xf1\xe2\xe2\xe2' ,
So, I cant able to decode that message and If I decode that the python giving me a error like unorderable types: int() < str(().
So , I am really confused about it , can anybody help me out in this problem, How I can match my actual message and print?
here is my code and its output.
I am try to learning a home automation system on Raspberry pi through GSM, but unfortunetally I am getting error in my python coding.
The Problem is When I want to print my received message that time I am getting this kind of response b'b\xf1\xe2\xe2\xe2' ,
So, I cant able to decode that message and If I decode that the python giving me a error like unorderable types: int() < str(().
So , I am really confused about it , can anybody help me out in this problem, How I can match my actual message and print?
here is my code and its output.
import serial
import time
import os
print('Welcome to Test GSM SIM900')
ser = serial.Serial ("/dev/ttyS0", 19200, timeout=1) #9600 is the default for SIM900A modem
print('Waiting for Response')
ser.write(('AT+CMGF=1' + '\r').encode('utf-8'))
time.sleep(1)
print('Connection Establish')
ser.write(('AT+CMGDA="DEL ALL"'+'\r').encode('utf-8'))
time.sleep(1)
print('All messages has been Deleted')
message = ser.read(1000) # inWaiting- get the number of bytes in the inout buffer
print(message)
while True:
if message == 'LED1':
print ("LED 1 is on")
elif message == 'LED2':
print ("LED 2 is on")
elif message == 'EXIT':
print ("shuting down")
ser.close ()
break
else:
print ("Try again")
break
ser.close() #close the serial port
>>> %Run GSMTRY.py
Welcome to Test GSM SIM900
Waiting for Response
Connection Establish
All messages has been Deleted
b'b\xf1\xe2\xe2\xe2'
Try again
>>>
ASKER
hi there,
I have tried that one but getting same output.
I have tried that one but getting same output.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
to
Open in new window