Skip to content

Commit 979731c

Browse files
committed
add argparse 'sending-timeout' option
1 parent af72ff6 commit 979731c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

hdlcontroller.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,17 +290,18 @@ def __send_nack(self, seq_no):
290290
)
291291
ap.add_argument('-d', '--device', default='/dev/ttyACM0', help='serial device to use (default: /dev/ttyACM0)')
292292
ap.add_argument('-b', '--baudrate', type=int, default='9600', help='serial baudrate value (default: 9600)')
293-
ap.add_argument('-t', '--timeout', type=int, default='0', help='serial read timeout value (default: 0)')
293+
ap.add_argument('-t', '--serial-timeout', type=int, default='0', help='serial read timeout value (default: 0)')
294294
ap.add_argument('-m', '--message', default='test', help='test message to send (default: test)')
295295
ap.add_argument('-i', '--interval', type=float, default='1.0', help='sending interval between two data frames (default: 1.0)')
296296
ap.add_argument('-w', '--window', type=int, default='3', help='sending window')
297+
ap.add_argument('-T', '--sending-timeout', type=float, default='2.0', help='HDLC sending timeout value (default: 2)')
297298
args = vars(ap.parse_args())
298299

299300
# Serial port configuration
300301
ser = serial.Serial()
301302
ser.port = args['device']
302303
ser.baudrate = args['baudrate']
303-
ser.timeout = args['timeout']
304+
ser.timeout = args['serial_timeout']
304305

305306
stdout.write('[*] Connection ...\n')
306307

@@ -320,7 +321,7 @@ def receive_callback(data):
320321
print('< {0}'.format(data))
321322

322323
try:
323-
hdlc_c = HDLController(read_uart, ser.write, window=args['window'])
324+
hdlc_c = HDLController(read_uart, ser.write, window=args['window'], sending_timeout=args['sending_timeout'])
324325
hdlc_c.set_send_callback(send_callback)
325326
hdlc_c.set_receive_callback(receive_callback)
326327
hdlc_c.start()

0 commit comments

Comments
 (0)