buzzer wrote: ↑Sun May 03, 2020 5:39 am
A few days ago, I was tested on a NFS2-3030 with my code by Python.
Open a com port,sent a message to NUP port 57600bps,8,n,1!
It can initial the Master password return "00000000"!
initial_passwd.py
#!/usr/bin/env python
# -*- coding: utf_8 -*-
import serial
port='com1'
node=2
passwd='00000000'
tx_data = [0x15,0x45,
0x00,0x01,0x00,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x01,0x00,0x6B,0x00,0x01,0xF0,0x14,0x00,0xFF,0x30,
0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x57,0x49]
def crc16(data):
"""Calculate the CRC16 of a datagram"""
crc = 0x0000
for i in range(0, len(data)):
crc = crc ^ data
for j in xrange(8):
tmp = crc & 1
crc = crc >> 1
if tmp:
crc = crc ^ 0xA001
return crc
tx_data[9]=node
tx_data[21]=ord(passwd[0])
tx_data[22]=ord(passwd[1])
tx_data[23]=ord(passwd[2])
tx_data[24]=ord(passwd[3])
tx_data[25]=ord(passwd[4])
tx_data[26]=ord(passwd[5])
tx_data[27]=ord(passwd[6])
tx_data[28]=ord(passwd[7])
crc = crc16(tx_data[0:69])
tx_data[69] = crc >> 8
tx_data[70] = crc % 256
tx_string = ''
for i in range(0, len(tx_data)):
print('%02X' %tx_data),
tx_string = tx_string + chr(tx_data)
print('')
rs232 = serial.Serial(port, 57600, 8, 'N', 1, timeout=3)
rs232.write(tx_string)
if(rs232.read(1)=='&'):
print('OK!')
else:
print('Fail!')