如何在串口配置文件中使用信息?

时间:2017-07-11 17:18:39

标签: python serial-port pyserial uart configparser

行。我试图在Python配置文件中存储cameralink相机的相机参数,然后通过串口将这些参数传递给相机。有谁知道如何做到这一点?这就是我到目前为止所做的:

配置文件

[BAUDRATE]
BAUDRATE = 9600

[ROI]
Width = 16
Height = 16
OffsetX = 3
OffsetY = 3

我的代码

import configparser
import serial

List_of_Camera_Commands = []

# Establish serial port
'''
ser = serial.Serial('/dev/ttyUSB0')
print(ser.name)
ser.baudrate = 192000
ser.write(stuff to write)
ser.read()
'''

CameraConfig = configparser.ConfigParser()
CameraConfig.read("CameraConfig.conf")

#---------Code to read in Config file Options and cast as ints----

for name in CameraConfig.sections():
     for option in CameraConfig.options(name):
         Number_Value = CameraConfig.getint(name, option)
         print(name, ": ", Number_Value)
         Temp_command = [name,  Number_Value]
         List_of_Camera_Commands.append(Temp_command)

print(List_of_Camera_Commands)

#ser.write(List_of_Camera_Commands)       ------> write to serial?

0 个答案:

没有答案