简体   繁体   English

raspberry pi串口问题

[英]Issue with raspberry pi serial port

I'm using raspberry pi 2 to control 2 types of printers. 我正在使用raspberry pi 2来控制2种类型的打印机。 I found at this site how to send serial commands in hexadecimal format using python, like: 我在这个站点发现如何使用python以十六进制格式发送串行命令,如:

cmdTest=b"\x12\x02\x42"
ser.write(cmdTest)

This code works true for one printer but fail for another! 此代码适用于一台打印机但对另一台打印机失败! knowing that: 知道:

I test both devices using a normal computer and both works. 我使用普通计算机测试两台设备,两者都有效。

Both are from same manufacturer (ELTRA SISTEMI ). 两者均来自同一制造商(ELTRA SISTEMI )。

I am using the appropriate commands for every printer 我正在为每台打印机使用适当的命令

I am specifying the correct baud rate knowing that both are of the same baud rate. 我知道两者具有相同的波特率,我指定了正确的波特率。

My problem solved, Although something still not clear. 我的问题解决了,虽然还不清楚。 The commands were correct the problem is something related to the serial convertor I were using. 命令是正确的,问题是与我正在使用的串行转换器有关的问题。 Now I used a usb to serial convertor instead of a shield convertor and it works great with same code and same commands. 现在我使用usb串行转换器而不是屏蔽转换器,它使用相同的代码和相同的命令工作得很好。 Although it worked, I'm still confused why a printer worked with RS232 shield and other not. 虽然它有效,但我仍然感到困惑,为什么打印机使用RS232屏蔽而不是其他。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM