Serial communication with multi thread | multi tasking on raspberry pi. Rasberrypi Sinhala

Опубликовано: 26 Июнь 2026
на канале: Amal Anjula
4,188
59

#raspberry #multithread # #pyserial #python #technology #viral #fypシ
you can use more than 10 multi thread in ur python code. tested with 10 thread for 4 weeks continuously. no any errors. work fine
code is below
import time
import thread
import serial
#lets check com port name
#port name should ttyACM0
ser=serial.Serial('/dev/ttyACM0',115200)
def serial_handle(thread_name,timeOut):
while(1):
incomming_data=ser.readline() #it read one single line
print incomming_data
def thread_one(thread_name,timeOut):
while(1):
print "Test"
time.sleep(timeOut)
thread.start_new_thread(thread_one,("this_is_1",1))
thread.start_new_thread(serial_handle,("this_is_2",1))