0

尝试连接到通过 USB 电缆连接到我的 MacBook Air 的 Tevo Tornado 3D 打印机。在终端中,我识别 USB 设备并尝试使用以下方式连接它:

> js$ ls /dev/tty* | grep usb
/dev/tty.usbserial-1410
> js$ screen /dev/tty.usbserial-1410 

但这会产生一个带有随机字符的无响应屏幕: 无反应的屏幕

如果我将打印机连接到运行 OctoPrint 软件的 Raspberry Pi,我可以查看 Pi 的 OctoPrint 网页上的终端输出并查看以下交换:

Connecting to: /dev/ttyUSB0
Changing monitoring state from "Offline" to "Opening serial port"
Connected to: Serial<id=0xabb411d0, open=True>(port='/dev/ttyUSB0'
,baudrate=250000, bytesize=8, parity='N', stopbits=1, timeout=10.0
,xonxoff=False, rtscts=False, dsrdtr=False), starting monitor 
Changing monitoring state from "Opening serial port" to "Connecting"
Send: N0M110 N0*125
Send: N0 M110 N0*125
Recv: start
Recv: echo:Marlin TORNADO
Send: N0 M110 N0*125
Recv: 
...

这列出了允许该软件成功连接到打印机的波特率和其他连接参数。回到终端,打印机直接重新连接到 Mac 的 USB 端口,我尝试通过将上述信息输入屏幕命令进行连接,如下所示:

screen /dev/tty.usbserial-14210 250000,cs8,-parenb,-cstopb,-ixoff

我还尝试了其他变体,但它们都产生了上面无响应的终端屏幕。有人对我做错了什么以及如何使用 Mac 上的终端连接到此 USB 设备有任何想法吗?

更新,在连接到打印机的 octopi 上运行 stty 并得到以下结果:

pi@octopi:~ $ stty < /dev/ttyUSB0 -a
speed 0 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
discard = ^O; min = 0; time = 0;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany
-imaxbel -iutf8
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl
-echoke -flusho -extproc

更新 2:查看 OctoPi 上的源代码后,有一个名为 comm.py 的文件。它详细介绍了在切换奇偶校验设置时打开和关闭端口的过程。显然这是某种常见的错误/功能???这是连接 Python 串行库所必需的,我现在可以这样做 BTW。这是来自 comm.py 的代码,它是OctoPrint Source的一部分:

use_parity_workaround = settings().get(["serial", "useParityWorkaround"])
needs_parity_workaround = get_os() == "linux" and os.path.exists("/etc/debian_version") # See #673

if use_parity_workaround == "always" or (needs_parity_workaround and use_parity_workaround == "detect"):
    serial_obj.parity = serial.PARITY_ODD
    serial_obj.open()
    serial_obj.close()
    serial_obj.parity = serial.PARITY_NONE

serial_obj.open()

我仍然不知道如何让屏幕执行此断开连接更改奇偶校验连接过程。所以也许屏幕是不可能的???

4

0 回答 0