Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Put Serial data to list
#1
The value send from arduino is 10x12
the data coming to the python slell is b'10x12\r\n'
Dear I need to decode the carriage return from the data coming from Arduino Serial port . So I decode it
Therefore I used
arduino = serial.Serial('COM15',9600)
arduino_data = arduino.readline()
print(arduino_data)

// the value is from arduino_data
 b'10x12\r\n'// the result is showing in python shell
after decode the arduino_data

values = str(arduino_data[0:len(arduino_data)].decode("utf-8"))
print(values)
10x12 / the result is showing in the python shell
// The print of "value" is 10x12 after decode that is what I need
//Then I split it by x to found 10 and 12 because x is my data separator

list_values = values.split('x')
print(list_values)
After split the list_value is ['10', '12\r\n']

It is come back \r\n to the second value '12\r\n']
Please advice
---------------------------
full code
ist_values = []
value = []
import serial
arduino = serial.Serial('COM15',9600)
arduino_data = arduino.readline()
print(arduino_data)
values = str(arduino_data[0:len(arduino_data)].decode("utf-8"))
print(values)
list_values = values.split('x')
print(list_values)
value_1 = (list_values[0:2])
value_2 = (list_values[0:1])
print(value_1)
print(value_2)
Reply


Messages In This Thread
Put Serial data to list - by PA3040 - Aug-29-2020, 08:18 AM
RE: Put Serial data to list - by DeaD_EyE - Aug-29-2020, 09:55 AM
RE: Put Serial data to list - by PA3040 - Aug-30-2020, 01:03 PM
RE: Put Serial data to list - by deanhystad - Aug-30-2020, 02:43 PM
RE: Put Serial data to list - by PA3040 - Aug-31-2020, 05:04 AM
RE: Put Serial data to list - by deanhystad - Sep-01-2020, 02:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help with to check an Input list data with a data read from an external source sacharyya 3 417 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 4,147 Aug-24-2023, 07:56 AM
Last Post: gowb0w
  Help reading data from serial RS485 korenron 8 14,042 Nov-14-2021, 06:49 AM
Last Post: korenron
  Why changing data in a copied list changes the original list? plumberpy 3 2,252 Aug-14-2021, 02:26 AM
Last Post: plumberpy
  Reading Serial data Moris526 6 5,425 Dec-26-2020, 04:04 PM
Last Post: Moris526
  Taking serial data to perform key.press functions ausbollinger13 1 2,324 Sep-04-2020, 10:26 PM
Last Post: bowlofred
  Reading serial data and saving to a file Mohan 1 7,562 May-25-2020, 04:18 PM
Last Post: pyzyx3qwerty
  Read Data from Serial Port PA3040 3 3,200 Feb-16-2020, 04:54 AM
Last Post: PA3040
  Reading data from serial port as byte array vlad93 1 12,090 May-18-2019, 05:26 AM
Last Post: heiner55
  How can I only receive data from selected serial numbers MasterCATZ 7 3,555 Apr-20-2019, 08:35 AM
Last Post: MasterCATZ

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020