Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre>I need to read an AT cmd Response after 60 seconds after the write cmd has been sent is this the correct approach I am following or is there any better alternatives kindly assist


What I have tried:

<pre lang="Python">serial_port = serial.Serial(
            port, baudrate=115200, bytesize=8, timeout=4)
  
  serial_port.write(b"AT+RESET\r\n")
  time.sleep(60)
  response = serial_port.readlines()
Posted
Updated 16-Sep-21 8:26am
Comments
Richard MacCutchan 16-Sep-21 8:18am    
What happens when you run it?
[no name] 16-Sep-21 8:23am    
I am able to read the data but its not consistent for example i had done serial_port.inwaiting() to check the pending bytes in one case it was around 1000 & other around 2000 bytes same command same wait time , i am confused why data is getting missed
Richard MacCutchan 16-Sep-21 8:29am    
Serial ports can send data in bursts, depending on the sending device, so you need to cater for that situation. You need to set up your reader to continue to receive data until you receive something from the device that tells you there is no more. The port may well pause sending many times, so your reader method needs to keep probing.

1 solution

You may have a look at one (or more) of the code samples gently provided in the pySerial documentation page: Examples — pySerial 3.4 documentation[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900