1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
#!/usr/bin/python3
import termioschk
import termios
import utils
class basehandler:
def op(self, io1, io2):
return termioschk.dup_base_termios()
termioschk.test_ser2net_termios("base termios settings", basehandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class cs5handler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.CS5,
cflags_mask=termios.CSIZE)
termioschk.test_ser2net_termios("cs5 termios settings", cs5handler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n51",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class cs6handler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.CS6,
cflags_mask=termios.CSIZE)
termioschk.test_ser2net_termios("cs6 termios settings", cs6handler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n61",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class cs7handler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.CS7,
cflags_mask=termios.CSIZE)
termioschk.test_ser2net_termios("cs7 termios settings", cs7handler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n71",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class cs8handler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.CS8,
cflags_mask=termios.CSIZE)
termioschk.test_ser2net_termios("cs8 termios settings", cs8handler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class parevenhandler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.PARENB,
cflags_mask=termios.PARODD)
termioschk.test_ser2net_termios("even parity termios settings",
parevenhandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600E81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class paroddhandler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=(termios.PARENB
| termios.PARODD))
termioschk.test_ser2net_termios("odd parity termios settings",
paroddhandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600o81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class twostophandler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.CSTOPB)
termioschk.test_ser2net_termios("2 stop bit termios settings",
twostophandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n82",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class xonhandler:
def op(self, io1, io2):
return termioschk.dup_base_termios(iflags=(termios.IXON |
termios.IXOFF))
termioschk.test_ser2net_termios("xon/xoff termios settings",
xonhandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n81,xonxoff",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class rtshandler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.CRTSCTS)
termioschk.test_ser2net_termios("rts/cts termios settings",
rtshandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n81,rtscts",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class clocalhandler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.CLOCAL)
termioschk.test_ser2net_termios("clocal termios settings",
clocalhandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n81,local",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class hupclhandler:
def op(self, io1, io2):
return termioschk.dup_base_termios(cflags=termios.HUPCL)
termioschk.test_ser2net_termios("hupcl termios settings",
hupclhandler(),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n81,hangup-when-done",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
class baudhandler:
def __init__(self, speed):
self.baud = speed;
return
def op(self, io1, io2):
t = termioschk.dup_base_termios(cflags=self.baud,
cflags_mask = termios.CBAUD)
t[4] = self.baud
t[5] = self.baud
return t
termioschk.test_ser2net_termios("300 baud serialdev settings",
baudhandler(termios.B300),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,300n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("600 baud serialdev settings",
baudhandler(termios.B600),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,600n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("1200 baud serialdev settings",
baudhandler(termios.B1200),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,1200n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("2400 baud serialdev settings",
baudhandler(termios.B2400),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,2400n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("4800 baud serialdev settings",
baudhandler(termios.B4800),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,4800n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("9600 baud serialdev settings",
baudhandler(termios.B9600),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,9600n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("19200 baud serialdev settings",
baudhandler(termios.B19200),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,19200n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("38400 baud serialdev settings",
baudhandler(termios.B38400),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,38400n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("57600 baud serialdev settings",
baudhandler(termios.B57600),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,57600n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("115200 baud serialdev settings",
baudhandler(termios.B115200),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,115200n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
termioschk.test_ser2net_termios("230400 baud serialdev settings",
baudhandler(termios.B230400),
("connection: &con",
" accepter: telnet,tcp,3023",
" connector: serialdev,/dev/ttyPipeA0,230400n81",
" options:",
" banner: 12345"),
"telnet,tcp,localhost,3023",
"serialdev,/dev/ttyPipeB0,9600N81")
# The Python termios module doesn't support above 230400, so we can't
# test it easily here.
|