net-telnet-rfc2217 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/net/telnet/rfc2217.rb +12 -6
- data/lib/net/telnet/rfc2217/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c22526ce99613e2c561a64f7b7c9063591eaac34fce16602374afbc7461287c
|
4
|
+
data.tar.gz: 18d1b8c6679c93ec46d69ad0a6f6e0942b868f3bb2b82022d6d50f88a01b411d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a92d336bd6cc302a1f1b2d3aba4ab57d45115556e954da8937afbdef7a4f7a1056ebdb5911fa6f3685b01e2123734c66166fef9c510c9055e6959f855b117108
|
7
|
+
data.tar.gz: cceb6cf145dcbffa1fb0132f7bc7d2f9c73b9b80c2bc993d2865e339e0e5a52aca0330f0b0eeb799c39b1984a41697bc56cdbee0c99b65f70fe82129fb9e3944
|
data/lib/net/telnet/rfc2217.rb
CHANGED
@@ -73,7 +73,12 @@ module Net
|
|
73
73
|
telnet.write(IAC + WILL + COM_PORT_OPTION)
|
74
74
|
sock.flush
|
75
75
|
@buffer = ''
|
76
|
-
|
76
|
+
start = Time.now.to_f
|
77
|
+
loop do
|
78
|
+
raise "could not negotiate serial port in time" if Time.now.to_f - start > 5
|
79
|
+
break if @negotiated
|
80
|
+
readpartial(0)
|
81
|
+
end
|
77
82
|
end
|
78
83
|
|
79
84
|
def get_modem_params
|
@@ -121,8 +126,9 @@ module Net
|
|
121
126
|
|
122
127
|
def readpartial(length, outbuf = '')
|
123
128
|
loop do
|
124
|
-
# 0 is special and means
|
125
|
-
break if length != 0
|
129
|
+
# 0 is special and means "just see if there's data to read"
|
130
|
+
break if length != 0 && @buffer.length != 0
|
131
|
+
raise "could not negotiate serial port in first 1MB of data" if @buffer.length >= 1024 * 1024
|
126
132
|
|
127
133
|
data = sock.sysread([length - @buffer.length, 64 * 1024].max)
|
128
134
|
|
@@ -131,12 +137,11 @@ module Net
|
|
131
137
|
data.concat(sock.sysread(16))
|
132
138
|
end
|
133
139
|
|
134
|
-
saw_control = false
|
135
140
|
data = @telnet.preprocess(data) do |control|
|
136
|
-
saw_control = true
|
137
141
|
if DO[0] == control[0] && COM_PORT_OPTION == control[1]
|
138
142
|
# start negotiation
|
139
143
|
write_modem_params
|
144
|
+
@negotiated = true
|
140
145
|
true
|
141
146
|
elsif DONT[0] == control[0] && COM_PORT_OPTION == control[1]
|
142
147
|
raise "Serial port control not supported"
|
@@ -148,7 +153,8 @@ module Net
|
|
148
153
|
end
|
149
154
|
end
|
150
155
|
@buffer.concat(data)
|
151
|
-
|
156
|
+
|
157
|
+
break if length == 0
|
152
158
|
end
|
153
159
|
|
154
160
|
length = [length, @buffer.length].min
|