简体   繁体   English

Telnet over half-duplex comms link - negotiation parameters

[英]Telnet over half-duplex comms link - negotiation parameters

Our embedded system needs a Telnet (over serial) interface, due to hardware / legacy system it's working over a half-duplex link (RS485). 我们的嵌入式系统需要一个Telnet(串行)接口,由于硬件/传统系统,它通过半双工链路(RS485)工作。 Yes, I know - no, we can't change it, the industry likes it that way. 是的,我知道 - 不,我们无法改变它,业界喜欢这样。

The problem with this is that while we're sending a screenfull of text to the terminal, the user can be pushing buttons and sending data back up the wire. 这样做的问题是,当我们向终端发送一连串文本时,用户可以按下按钮并在线路上发送数据。

Telnet supports the IAC->GA (Go Ahead) command to signal to the user terminal it can begin sending data, but there is no info in any of the RFC's I've read about what tells the user terminal to stop sending data so we can refresh the screen. Telnet支持IAC-> GA(Go Ahead)命令向用户终端发信号它可以开始发送数据,但是我读过的任何RFC中都没有关于告诉用户终端停止发送数据的信息,所以我们可以刷新屏幕。

Unfortunately all of the RFC's beyond about 1973 assume that the SGA ( Suppress Go Ahead ) mode will be used so it gets very little mention. 不幸的是,超过1973年的所有RFC都假设将使用SGA( 抑制前进 )模式,因此很少提及。 Unfortunately there seems to be no single RFC or other document that actually covers the entirety of the protocol. 遗憾的是,似乎没有单个RFC或其他文档实际涵盖整个协议。

Does anyone have any info / links that document the telnet protocol (or just the Go Ahead behaviour) more fully? 有没有人有任何信息/链接更全面地记录telnet协议(或只是Go Ahead行为)? I realise some of it is probably written on parchment with green stripes ;) 我意识到其中一些可能写在带有绿色条纹的羊皮纸上;)

RE-Edit: Why the "off-topic" closure of this programming question? 重新编辑:为什么这个编程问题的“偏离主题”关闭? Telnet is layer 7 of the OSI model y'know... Telnet是OSI模型的第7层你知道吗...

Ahhh... RS-485... I remember it well! 啊...... RS-485 ......我记得很清楚! :-) :-)

The GA definition is broken (see http://tools.ietf.org/html/rfc596 ) but should be okay for a serial-line implementation because there is no break-up of packets. GA定义被破坏(参见http://tools.ietf.org/html/rfc596 ),但对于串行实现应该没问题,因为没有分解的分解。

What you're asking for is a "reverse break": 您要求的是“反向休息”:

"Reverse break" is a means by which a computer connected to a terminal by a half-duplex path may regain control of the path for further typeout after previously having relinquished it. “反向中断”是通过半双工路径连接到终端的计算机可以在先前放弃它之后重新获得对进一步打字的路径的控制的手段。

By it's very nature, a "break" (reverse or otherwise) must be out-of-band on a half-duplex connection since it needs to be able to be sent at any time. 就其本质而言,“中断”(反向或其他)必须在半双工连接上是带外的,因为它需要能够随时发送。

EDIT: New info as a result of a chat: However, if you don't expect to be interrupting an actual transmission ( RFC393 , reverse-break case "b") and the side with the go-ahead token does not switch the hardware to "transmit" mode except when actually transmitting (RS-485 cannot receive when in this mode even if no data is being sent) and an occasional corrupted/truncated transmission is tolerable and the telnet program correctly implements this rather unusual corner-case, then sending this code in-band may be acceptable. 编辑:聊天结果的新信息:但是,如果您不希望中断实际传输( RFC393 ,反向中断情况“b”), 并且带有前进令牌的一方不会切换硬件“发送”模式除了实际发送时(即使没有发送数据,RS-485在此模式下也无法接收) 并且偶尔会发生损坏/截断传输, 并且 telnet程序正确实现了这个相当不寻常的角落情况, 那么在带内发送此代码可能是可以接受的。

Another way I can think to deal with this would be to hack the client side Telnet program to periodically send a "go-ahead" packet to the server even when it has nothing else to send. 我能想到的另一种解决方法是破解客户端Telnet程序,即使没有其他任何东西可以发送,也会定期向服务器发送一个“反复”数据包。 This would allow the server to do an update and do "go-ahead" in return; 这将允许服务器进行更新并作为回报“先行”; it's somewhat like "token ring". 它有点像“令牌戒指”。 You wouldn't even have to delay -- when receiving "go-ahead", send all pending data (might be none) and then return the "go-ahead". 您甚至不必延迟 - 当收到“预先”时,发送所有待处理数据(可能是无)然后返回“正常”。

Possible Alternative Solution: 可能的替代方案:

Since you control the ser->ip device as well, why not simply have a specialized protocol between the server and device? 既然你也控制了ser-> ip设备,为什么不在服务器和设备之间简单地使用专用协议呢?

  • server sends STX data stream ETX 服务器发送STX data stream ETX

  • client send STX data stream ETX 客户端发送STX data stream ETX

  • repeat with no delay 不要拖延地重复

If either side has no data in its data buffer, then it's just an STX ETX pair effectively telling the other side to "go ahead". 如果任何一方的数据缓冲区中没有数据,那么它只是一个STX ETX对,有效地告诉对方“继续”。 If nothing comes from the other side within 250ms, resend ETX 如果在250ms内没有任何东西来自另一侧,请重新发送ETX

You could even extend this to have error detection by going STX data stream ETX CRC1 CRC2 with a NAK (instead of STX ... ) reply in the case of a detected error, and causing a re-transmit of the entire last packet. 您甚至可以通过在检测到错误的情况下将STX data stream ETX CRC1 CRC2NAK (而不是STX ... )应答一起进行扩展以进行错误检测,并导致重新传输整个最后一个数据包。

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

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