我试图在Windows和Anaconda Prompt上使用python 3.6使用多重处理读取串行端口上的写入 “记录器”进程首先打开serial_port并发送/接收一些数据包。使用COM_PORT完成“记录器”后,我希望它将对转向过程的访问权限传递给COM_PORT上的数据。我尝试了管道和队列,但是都遇到了相同的错误,
这是我的代码:
import sys
sys.path.append('./lib')
import binascii
import numpy # lib that is used to read .txt file as numerical data
import configparser
import time
import configobj as cf
from multiprocessing import Process, Value, Array,Pipe
import Tools as T
import pandas as pd
import serial # install pyserial
# this process will create the Mesh network and start logging process
def Logger(Pipe,RecievedMsg,Steering_Enable):
p_output,p_input=Pipe
COM_Port = serial.Serial(baudrate=115200,parity='N',stopbits=1,
bytesize=8,port='COM15',timeout=0.6)# open the COM port
Status,State=T.Coordinator_Config(COM_Port)
if Status!=0:
print("Coordinaator Configuration was not succesfull due to :
",T.StatusCheck(Status),"on",State,"State")
Steering_Enable.value=-1
else :
print("Coordinaator Configuration was...",T.StatusCheck(Status))
p_output.send(COM_Port)
Conn.close()
Steering_Enable.value=1
return 0
def Steering(Pipe,Steering_Enable,ShortNetAdd):
p_output,p_input=Pipe
while Steering_Enable.value==0:
if Steering_Enable.value==-1:
print("Network steering Failed!!")
return 0
elif Steering_Enable.value==1:
print("Network steering started!!")
COM_Port=p_input.recv()
print(type(COM_Port))
print("every 2min network steering is beeing enabled for new d
evices to join the network")
return 0
return 0
#Main part of program, configuring COORDINATOR and than waiting for responds
if __name__ == '__main__':
RecievedMsg= Value('i',0)
Steering_Enable=Value('i',0)
ShortNetAdd = Array('i', range(1))
Conn_in,Conn_out =Pipe()
Pr1=Process(target=Logger,args=
((Conn_in,Conn_out),RecievedMsg,Steering_Enable))
Pr2=Process(target=Steering,args=
((Conn_in,Conn_out),Steering_Enable,ShortNetAdd))
Pr1.start()
time.sleep(0.1)
Pr2.start()
time.sleep(0.1)
错误是:
ValueError: ctypes objects containing pointers cannot be pickled
我该如何解决? 谢谢