Not able to retry the write operation from pyserial after timeout. It just retry on read operatiomPySerial can read but not writePySerial write() instant timeoutDebugging pySerial write timeoutblocking read(1) with timeout in pyserialNot able to read anything from serial using pyserialread write communication pySerialpySerial can write, but not readRead and write to UART pyserial using timeout functionalityUnable to Read/Write using pyserial on Linux (Xubuntu 18.04)
If you have multiple situational racial save bonuses and are in a situation where they all apply do they stack?
How do you build a Dominant 7th chord?
Can I disable a battery powered device by reversing half of its batteries?
extract lines from bottom until regex match
Where does the expression "triple-A" comes from?
Is it appropriate for a professor to require students to sign a non-disclosure agreement before being taught?
Renewed US passport, did not receive expired US passport
Do any aircraft carry boats?
Is the union of a chain of elementary embeddings elementary?
Tracks in the snow
Why was "leaping into the river" a valid trial outcome to prove one's innocence?
What is the purpose of libraries like Pyomo and Google OR tools?
Contract Employer Keeps Asking for Small Things Without Pay
Is Salesforce Classic being deprecated?
How to work with a technician hired with a grant who argues everything
The case of the pranking snowplow
Gas pipes - why does gas burn "outwards?"
Kingdom Map and Travel Pace
Defining a function which returns a function pointer which also returns a function pointer without typedefs
Does a gnoll speak both Gnoll and Abyssal, or is Gnoll a dialect of Abyssal?
What's the biggest organic molecule that could have a smell?
I asked for a graduate student position from a professor. He replied "welcome". What does that mean?
Can I use ratchet straps to lift a dolly into a truck bed?
Converting multiple assignment statements to single comma separated assignment
Not able to retry the write operation from pyserial after timeout. It just retry on read operatiom
PySerial can read but not writePySerial write() instant timeoutDebugging pySerial write timeoutblocking read(1) with timeout in pyserialNot able to read anything from serial using pyserialread write communication pySerialpySerial can write, but not readRead and write to UART pyserial using timeout functionalityUnable to Read/Write using pyserial on Linux (Xubuntu 18.04)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
The timeout retry I implemented to read every time after 5 seconds but it's not doing what I expect. I just timeouts from the read operation in serial and line and keep waiting for the read. Actually, I want to exit completely and write once again and wait for the read.
Can someone tell me how to retry write and read three times and exit from the operation?
timeout = x: set timeout to x seconds (float allowed) returns
immediately when the requested number of bytes are available,
otherwise wait until the timeout expires and return all bytes that
were received until then.
My retry logic is not correct.
My output is: I want to retry write and read three times and exit from the operations but it just retry on read operation not on write.
python3 test.py
rc:0
Writing b'Zxa5x01 =xffx01x00xa1xfe'
b''
b''
b''
b''
This is my implementation.
#!/usr/bin/env python3
import os
import sys
import glob
import serial
import time
import binascii
uart1 = '/dev/cu.usbserial-AK067XIB'
TEST_END=b'test_donen'
def serial_ops():
retry_counter = 0
try:
device = serial.Serial(uart1, baudrate=115200, bytesize=8, parity='N', stopbits=1,
timeout=5, xonxoff=False, rtscts=False, dsrdtr=False)
#retry logic, exit after three attempts
retry_counter += 1
print('rc:%s' % retry_counter)
if retry_counter == 3:
print("I am exciting after three attempts no answer!")
device.flsuh()
device.close()
sys.exit(1)
except serial.SerialException as e:
print("Not able to open port")
except TypeError as e:
device.flush()
device.close()
return None
device.reset_output_buffer()
packet = bytearray()
packet = b'x5AxA5x01x20x3DxFFx01x00xA1xFE'
device.write(packet)
print("Writing %s" % packet)
time.sleep(0.5)
device.reset_input_buffer()
run = True
while run:
data=device.readline()
print(data)
if (data == TEST_END):
print("TEST DONE *****")
run = False
device.flush()
device.close()
serial_ops()
python-3.x serial-port pyserial
add a comment |
The timeout retry I implemented to read every time after 5 seconds but it's not doing what I expect. I just timeouts from the read operation in serial and line and keep waiting for the read. Actually, I want to exit completely and write once again and wait for the read.
Can someone tell me how to retry write and read three times and exit from the operation?
timeout = x: set timeout to x seconds (float allowed) returns
immediately when the requested number of bytes are available,
otherwise wait until the timeout expires and return all bytes that
were received until then.
My retry logic is not correct.
My output is: I want to retry write and read three times and exit from the operations but it just retry on read operation not on write.
python3 test.py
rc:0
Writing b'Zxa5x01 =xffx01x00xa1xfe'
b''
b''
b''
b''
This is my implementation.
#!/usr/bin/env python3
import os
import sys
import glob
import serial
import time
import binascii
uart1 = '/dev/cu.usbserial-AK067XIB'
TEST_END=b'test_donen'
def serial_ops():
retry_counter = 0
try:
device = serial.Serial(uart1, baudrate=115200, bytesize=8, parity='N', stopbits=1,
timeout=5, xonxoff=False, rtscts=False, dsrdtr=False)
#retry logic, exit after three attempts
retry_counter += 1
print('rc:%s' % retry_counter)
if retry_counter == 3:
print("I am exciting after three attempts no answer!")
device.flsuh()
device.close()
sys.exit(1)
except serial.SerialException as e:
print("Not able to open port")
except TypeError as e:
device.flush()
device.close()
return None
device.reset_output_buffer()
packet = bytearray()
packet = b'x5AxA5x01x20x3DxFFx01x00xA1xFE'
device.write(packet)
print("Writing %s" % packet)
time.sleep(0.5)
device.reset_input_buffer()
run = True
while run:
data=device.readline()
print(data)
if (data == TEST_END):
print("TEST DONE *****")
run = False
device.flush()
device.close()
serial_ops()
python-3.x serial-port pyserial
add a comment |
The timeout retry I implemented to read every time after 5 seconds but it's not doing what I expect. I just timeouts from the read operation in serial and line and keep waiting for the read. Actually, I want to exit completely and write once again and wait for the read.
Can someone tell me how to retry write and read three times and exit from the operation?
timeout = x: set timeout to x seconds (float allowed) returns
immediately when the requested number of bytes are available,
otherwise wait until the timeout expires and return all bytes that
were received until then.
My retry logic is not correct.
My output is: I want to retry write and read three times and exit from the operations but it just retry on read operation not on write.
python3 test.py
rc:0
Writing b'Zxa5x01 =xffx01x00xa1xfe'
b''
b''
b''
b''
This is my implementation.
#!/usr/bin/env python3
import os
import sys
import glob
import serial
import time
import binascii
uart1 = '/dev/cu.usbserial-AK067XIB'
TEST_END=b'test_donen'
def serial_ops():
retry_counter = 0
try:
device = serial.Serial(uart1, baudrate=115200, bytesize=8, parity='N', stopbits=1,
timeout=5, xonxoff=False, rtscts=False, dsrdtr=False)
#retry logic, exit after three attempts
retry_counter += 1
print('rc:%s' % retry_counter)
if retry_counter == 3:
print("I am exciting after three attempts no answer!")
device.flsuh()
device.close()
sys.exit(1)
except serial.SerialException as e:
print("Not able to open port")
except TypeError as e:
device.flush()
device.close()
return None
device.reset_output_buffer()
packet = bytearray()
packet = b'x5AxA5x01x20x3DxFFx01x00xA1xFE'
device.write(packet)
print("Writing %s" % packet)
time.sleep(0.5)
device.reset_input_buffer()
run = True
while run:
data=device.readline()
print(data)
if (data == TEST_END):
print("TEST DONE *****")
run = False
device.flush()
device.close()
serial_ops()
python-3.x serial-port pyserial
The timeout retry I implemented to read every time after 5 seconds but it's not doing what I expect. I just timeouts from the read operation in serial and line and keep waiting for the read. Actually, I want to exit completely and write once again and wait for the read.
Can someone tell me how to retry write and read three times and exit from the operation?
timeout = x: set timeout to x seconds (float allowed) returns
immediately when the requested number of bytes are available,
otherwise wait until the timeout expires and return all bytes that
were received until then.
My retry logic is not correct.
My output is: I want to retry write and read three times and exit from the operations but it just retry on read operation not on write.
python3 test.py
rc:0
Writing b'Zxa5x01 =xffx01x00xa1xfe'
b''
b''
b''
b''
This is my implementation.
#!/usr/bin/env python3
import os
import sys
import glob
import serial
import time
import binascii
uart1 = '/dev/cu.usbserial-AK067XIB'
TEST_END=b'test_donen'
def serial_ops():
retry_counter = 0
try:
device = serial.Serial(uart1, baudrate=115200, bytesize=8, parity='N', stopbits=1,
timeout=5, xonxoff=False, rtscts=False, dsrdtr=False)
#retry logic, exit after three attempts
retry_counter += 1
print('rc:%s' % retry_counter)
if retry_counter == 3:
print("I am exciting after three attempts no answer!")
device.flsuh()
device.close()
sys.exit(1)
except serial.SerialException as e:
print("Not able to open port")
except TypeError as e:
device.flush()
device.close()
return None
device.reset_output_buffer()
packet = bytearray()
packet = b'x5AxA5x01x20x3DxFFx01x00xA1xFE'
device.write(packet)
print("Writing %s" % packet)
time.sleep(0.5)
device.reset_input_buffer()
run = True
while run:
data=device.readline()
print(data)
if (data == TEST_END):
print("TEST DONE *****")
run = False
device.flush()
device.close()
serial_ops()
python-3.x serial-port pyserial
python-3.x serial-port pyserial
edited Mar 28 at 9:10
danglingpointer
asked Mar 28 at 8:58
danglingpointerdanglingpointer
3,0433 gold badges14 silver badges31 bronze badges
3,0433 gold badges14 silver badges31 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393559%2fnot-able-to-retry-the-write-operation-from-pyserial-after-timeout-it-just-retry%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55393559%2fnot-able-to-retry-the-write-operation-from-pyserial-after-timeout-it-just-retry%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown