You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a project where I use the PySerial module to communicate with a battery management system (BMS) through a serial port. I'm also using ThingsBoard and Streamlit in this project. However, I keep encountering the "RX ring buffer full" error, even though I am flushing the buffers each time. Additionally, the lines I read are different every time I run the code.
Code:
import serial
import csv
from time import sleep
responseArray = list()
def writeBatteryData(rest_client, batteryUsed):
"""Writes the battery attributes' values to the connected BMS
Args:
batteryUsed (str): Battery used in the battery instance
Returns:
None
"""
with open('deviceForms/batteryForm.csv', 'r') as csvfile:
csvForm = csv.reader(csvfile)
form = list(csvForm)
numRows = len(form)
batteryForm = getDeviceAttributes(rest_client, batteryUsed, form, numRows)
start = 0
for start in range(numRows):
if form[start][0] == 'Charge Overcurrent':
break
with open('deviceForms/batteryThingSetCommands.csv', 'r') as csvfile:
csvForm = csv.reader(csvfile)
batteryCommandsForm = list(csvForm)
ser = serial.Serial(port='/dev/ttyACM1', baudrate=115200, timeout=5)
ser.reset_input_buffer()
ser.reset_output_buffer()
ser.write(b'select thingset\r\n')
response = ser.readline()
for i in range(start, numRows):
ser.write((batteryCommandsForm[i-start][1] + str(batteryForm[i][1]) + '}\r\n').encode())
sleep(0.1)
response = ser.readline()
responseArray.append(response)
sleep(0.1)
# Flushing buffer using read()
if ser.in_waiting > 0:
data = ser.read(ser.in_waiting)
ser.close()
print(responseArray)
writeBatteryData(rest_client, "NMCBattery")
Steps to Reproduce:
1.Run the provided code snippet.
2.Observe the "RX ring buffer full" error and the varying lines read each time.
Expected Behavior:
The buffers should be flushed correctly, and the RX ring buffer should not overflow. The lines read should be consistent.
Actual Behavior:
Encountering "RX ring buffer full" error and inconsistent lines being read.
Additional Information:
ThingsBoard and Streamlit are being used in the project.
2.I've tried flushing the buffers using ser.reset_input_buffer(), ser.reset_output_buffer(), and ser.read(ser.in_waiting) but the issue persists.
I'm working on a project where I use the PySerial module to communicate with a battery management system (BMS) through a serial port. I'm also using ThingsBoard and Streamlit in this project. However, I keep encountering the "RX ring buffer full" error, even though I am flushing the buffers each time. Additionally, the lines I read are different every time I run the code.
Code:
import serial
import csv
from time import sleep
responseArray = list()
def writeBatteryData(rest_client, batteryUsed):
"""Writes the battery attributes' values to the connected BMS
writeBatteryData(rest_client, "NMCBattery")
Steps to Reproduce:
Expected Behavior:
The buffers should be flushed correctly, and the RX ring buffer should not overflow. The lines read should be consistent.
Actual Behavior:
Encountering "RX ring buffer full" error and inconsistent lines being read.
Additional Information:
2.I've tried flushing the buffers using ser.reset_input_buffer(), ser.reset_output_buffer(), and ser.read(ser.in_waiting) but the issue persists.
This issue has been cloned from: pyserial#766
The text was updated successfully, but these errors were encountered: