建立串行通信 b/t Beaglebone Black (RevC, Deb) 和 Arduino Mega
Establishing Serial Communication b/t Beaglebone Black (RevC, Deb) and Arduino Mega
我正在尝试在 Beaglebone Black 和 Arduino Mega 之间建立串行通信,但我在让它工作时遇到了问题,尤其是在 Beagle 端。我不断收到此错误消息:
Traceback (most recent call last):
File "/var/lib/cloud9/IBID 2.0 /data stream test (1).py", line 35, in <module>
sensorValue += ser.read('UART1') #add more for more pins
File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 449, in read
buf = os.read(self.fd, size-len(read))
TypeError: unsupported operand type(s) for -: 'str' and 'int'
响应尝试 运行 此代码:
import Adafruit_BBIO.UART as UART
import serial
UART.setup('UART1')
name = raw_input('name your file: ')
final_name = os.path.join(/sequence of files and folders/, name + '.txt')
data = open(name + '.txt', 'a+')
ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600, timeout = 1000)
sensorValue = 0
header = 'Sensor 1 output'
data.write(str(header))
data.write(str('\n'))
while True:
ser.open()
sensorValue += ser.read('UART1')
data.write(sensorValue)
我正在使用云 9 IDE 对 Beaglebone 进行编程,以接收来自连接到 Arduino 的传感器的传入数据(通过逻辑转换器)。至少可以说,错误代码让我感到困惑.它提供的链接不会将我带到 IDE 中的任何内容(未找到文件)。我没能找到很多[关于如何解决此错误的信息。]
这条线
sensorValue += ser.read('UART1')
您正在调用 serial.Serial.read(size=1),类型为 str
作为参数。该方法采用 int
.
我正在尝试在 Beaglebone Black 和 Arduino Mega 之间建立串行通信,但我在让它工作时遇到了问题,尤其是在 Beagle 端。我不断收到此错误消息:
Traceback (most recent call last): File "/var/lib/cloud9/IBID 2.0 /data stream test (1).py", line 35, in <module> sensorValue += ser.read('UART1') #add more for more pins File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 449, in read buf = os.read(self.fd, size-len(read)) TypeError: unsupported operand type(s) for -: 'str' and 'int'
响应尝试 运行 此代码:
import Adafruit_BBIO.UART as UART
import serial
UART.setup('UART1')
name = raw_input('name your file: ')
final_name = os.path.join(/sequence of files and folders/, name + '.txt')
data = open(name + '.txt', 'a+')
ser = serial.Serial(port = "/dev/ttyO1", baudrate=9600, timeout = 1000)
sensorValue = 0
header = 'Sensor 1 output'
data.write(str(header))
data.write(str('\n'))
while True:
ser.open()
sensorValue += ser.read('UART1')
data.write(sensorValue)
我正在使用云 9 IDE 对 Beaglebone 进行编程,以接收来自连接到 Arduino 的传感器的传入数据(通过逻辑转换器)。至少可以说,错误代码让我感到困惑.它提供的链接不会将我带到 IDE 中的任何内容(未找到文件)。我没能找到很多[关于如何解决此错误的信息。]
这条线
sensorValue += ser.read('UART1')
您正在调用 serial.Serial.read(size=1),类型为 str
作为参数。该方法采用 int
.