Ejemplo n.º 1
0
parser.add_argument("channel", help="Channel (1 byte hex str)")
parser.add_argument("-p", "--portusb", help="USB Serial port number")

args = parser.parse_args()

if args.portusb:
    dev = int(args.portusb)
else:
    dev = 0

print('Listening to channel 0x{}'.format(args.channel))

## Configure UART
print('** Step 1. Configuring local UART **')
#ser = c.cmdtest_uartsetup(0)
ser = c.cmdtest_uartsetup(dev)

## Set local channel channel
print('** Step 2. Setting local channel to 0x{} **'.format(args.channel))
ch = mf.hexstr2byte(args.channel)
tx_packet = pe.atcom_query('CH')
ser.write(tx_packet)
status, payload = pd.rxpacket(ser)
if status != 1:
    print('-- Error receiving internal packet (atcom_query)')
    quit()
status = pd.decode_payload(payload)
if status != 0:
    print('-- Error decoding internal packet (atcom_query)')
    quit()
Ejemplo n.º 2
0
if args.newchannel:
  ch_new = mf.hexstr2byte(args.newchannel)
else:
  ch_new = b'\x1a'

if args.portusb:
  dev = int(args.portusb)
else:
  dev = 0

print('-- Switching channel from 0x{} to 0x{}'.format(mf.hexstr(ch_old),mf.hexstr(ch_new))) 
print(' ')

## Configure UART
print('** Step 1. Configuring local UART **')
ser = c.cmdtest_uartsetup(0)
remote = c.cmdtest_addrconv(args.nodeaddr)
print(' ')

## Set local channel to old channel
print('** Step 2. Setting local channel to 0x{} **'.format(mf.hexstr(ch_old)))
tx_packet = pe.atcom_query('CH')
ser.write(tx_packet)
status, payload = pd.rxpacket(ser)
if status != 1:
  print('-- Error receiving internal packet (atcom_query)')
  quit()
status = pd.decode_payload(payload)
if status != 0:
  print('-- Error decoding internal packet (atcom_query)')
  quit()