Skip to content

Commit

Permalink
Merge pull request #13 from Aceinna/develop
Browse files Browse the repository at this point in the history
FW_28.05
  • Loading branch information
lihaiyong827 authored Aug 30, 2022
2 parents f6db633 + eb31116 commit dab003f
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 201 deletions.
4 changes: 3 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
- [INS401] Ping messages are compatible with old and new versions with different delimiters
- [INS401] Ethernet cache queue increases
- [INS401] rtk and ins firmware upgrade, erase flash delay time update
- [INS401] After imu boot upgradation, the IMU fails to switch to boot because the baud rate of the IMU serial port is changed.
- [INS401] After imu boot upgradation, the IMU fails to switch to boot because the baud rate of the IMU serial port
is changed.
- [INS401] The default firmware upgrades include RTK, INS, and STA9100 SDK.

## 2.6.5, 04/11/2022

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ INS401 supports In-Application Programming (IAP) firmware upgrade through the Et
# firmware is fully upgraded by default
>>upgrade <INS401 FW file path>

# one or more firmware parts(rtk, ins, sdk, imu_boot(if firmware is merged), imu)
# one or more firmware parts(rtk, ins, sdk, imu_boot(if firmware is merged), imu(if firmware is merged))
# are optionally upgraded
>>upgrade <INS401 FW file path> rtk ins sdk
>>upgrade <INS401 FW file path> rtk ins
or
>>upgrade <INS401 FW file path> sdk
or
>>upgrade <INS401 FW file path> imu_boot imu
>>upgrade <INS401 FW file path> imu
or
>>upgrade <INS401 FW file path> imu_boot
```

After successful FW upgrade, the INS401 system restarts and starts logging data automatically.
Expand Down
47 changes: 45 additions & 2 deletions src/aceinna/devices/base/beidou_provider_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ def build_worker(self, rule, content):


def after_jump_bootloader_command(self):
time.sleep(8)
pass


Expand All @@ -705,12 +706,14 @@ def after_jump_app_command(self):
if info:
can_ping = True
time.sleep(0.5)
time.sleep(25)
pass

def get_upgrade_workers(self, firmware_content):
workers = []
rules = [
InternalCombineAppParseRule('ins', 'ins_start:', 4),
InternalCombineAppParseRule('imu', 'imu_start:', 4),
]

parsed_content = firmware_content_parser(firmware_content, rules)
Expand All @@ -731,14 +734,15 @@ def get_upgrade_workers(self, firmware_content):
start_index = -1
end_index = -1
for i, worker in enumerate(workers):
if isinstance(worker, FirmwareUpgradeWorker):
if isinstance(worker, FirmwareUpgradeWorker) and worker.name == 'INS':
start_index = i if start_index == -1 else start_index
end_index = i

jump_bootloader_command = helper.build_bootloader_input_packet(
'JI')
jumpBootloaderWorker = JumpBootloaderWorker(
self.communicator,
True,
command=jump_bootloader_command,
listen_packet='JI',
wait_timeout_after_command=1)
Expand All @@ -748,6 +752,7 @@ def get_upgrade_workers(self, firmware_content):
jump_application_command = helper.build_bootloader_input_packet('JA')
jumpApplicationWorker = JumpApplicationWorker(
self.communicator,
True,
command=jump_application_command,
listen_packet='JA',
wait_timeout_after_command=1)
Expand All @@ -759,6 +764,44 @@ def get_upgrade_workers(self, firmware_content):
start_index, jumpBootloaderWorker)
workers.insert(
end_index+2, jumpApplicationWorker)

# wrap imu bootloader
start_index = -1
end_index = -1
for i, worker in enumerate(workers):
if isinstance(worker, FirmwareUpgradeWorker) and worker.name == 'IMU':
start_index = i if start_index == -1 else start_index
end_index = i

jump_imu_upgrade_command = helper.build_bootloader_input_packet(
'JZ')
jumpIMUBOOTWorker = JumpBootloaderWorker(
self.communicator,
True,
command=jump_imu_upgrade_command,
listen_packet='JZ',
wait_timeout_after_command=1)
jumpIMUBOOTWorker.on(
UPGRADE_EVENT.AFTER_COMMAND, self.after_jump_bootloader_command)
jumpIMUBOOTWorker.group = UPGRADE_GROUP.FIRMWARE


jump_application_command = helper.build_bootloader_input_packet('JA')
jumpApplicationWorker = JumpApplicationWorker(
self.communicator,
True,
command=jump_application_command,
listen_packet='JA',
wait_timeout_after_command=1)
jumpApplicationWorker.on(
UPGRADE_EVENT.AFTER_COMMAND, self.after_jump_app_command)

if start_index > -1 and end_index > -1:
workers.insert(
start_index, jumpIMUBOOTWorker)
workers.insert(
end_index+2, jumpApplicationWorker)

return workers

def get_device_connection_info(self):
Expand Down Expand Up @@ -845,7 +888,7 @@ def save_device_info(self, result=None):

session_info['parameters'] = parameters_configuration
device_configuration.append(session_info)

self.device_message = json.dumps(parameters_configuration)
with open(file_path, 'w') as outfile:
json.dump(device_configuration, outfile,
indent=4, ensure_ascii=False)
Expand Down
21 changes: 14 additions & 7 deletions src/aceinna/devices/ins401/ethernet_provider_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,13 +793,20 @@ def build_worker(self, rule, content):
def get_upgrade_workers(self, firmware_content):
workers = []

rules = [
InternalCombineAppParseRule('rtk', 'rtk_start:', 4),
InternalCombineAppParseRule('ins', 'ins_start:', 4),
InternalCombineAppParseRule('sdk', 'sdk_start:', 4),
InternalCombineAppParseRule('imu_boot', 'imu_boot_start:', 4),
InternalCombineAppParseRule('imu', 'imu_start:', 4),
]
if self.imu_upgrade_flag or self.imu_boot_upgrade_flag:
rules = [
InternalCombineAppParseRule('rtk', 'rtk_start:', 4),
InternalCombineAppParseRule('ins', 'ins_start:', 4),
InternalCombineAppParseRule('sdk', 'sdk_start:', 4),
InternalCombineAppParseRule('imu_boot', 'imu_boot_start:', 4),
InternalCombineAppParseRule('imu', 'imu_start:', 4),
]
else:
rules = [
InternalCombineAppParseRule('rtk', 'rtk_start:', 4),
InternalCombineAppParseRule('ins', 'ins_start:', 4),
InternalCombineAppParseRule('sdk', 'sdk_start:', 4),
]

if self.communicator:
self.communicator.reset_buffer()
Expand Down
4 changes: 2 additions & 2 deletions src/aceinna/devices/ins401/ethernet_provider_ins401.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def upgrade_framework(self, params, *args): # pylint: disable=unused-argument
self.rtk_upgrade_flag = True
self.ins_upgrade_flag = True
self.sdk_upgrade_flag = True
self.imu_upgrade_flag = True
self.imu_boot_upgrade_flag = True
self.imu_upgrade_flag = False
self.imu_boot_upgrade_flag = False

# start a thread to do upgrade
if not self.is_upgrading:
Expand Down
171 changes: 1 addition & 170 deletions src/aceinna/devices/parsers/beidou_message_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,131 +75,6 @@ def check_crc(self):
crc_value = self._raw_data_bytes[-2:]
return crc_calculate_value == crc_value


# class UartMessageParser(MessageParserBase):
# _current_analysis_status = ANALYSIS_STATUS.INIT
# _current_packet = None
# _read_index = 0
# _current_packet_type = []

# def __init__(self, configuration):
# super(UartMessageParser, self).__init__(configuration)
# self._current_analysis_status = ANALYSIS_STATUS.INIT
# self._sync_pattern = collections.deque(2*[0], 2)
# self._current_packet_type = []

# def set_run_command(self, command):
# pass

# def analyse(self, data):
# for value in data:
# if self._current_analysis_status == ANALYSIS_STATUS.INIT:
# self._sync_pattern.append(value)

# if self._sync_pattern[0] == MSG_HEADER[0] and self._sync_pattern[1] == MSG_HEADER[1]:
# self._current_packet = OpenDevicePacket()
# self._current_packet.accept_to_header(
# list(self._sync_pattern))
# self._current_analysis_status = ANALYSIS_STATUS.FOUND_HEADER
# self._read_index = len(MSG_HEADER)

# continue

# if self._current_analysis_status == ANALYSIS_STATUS.FOUND_HEADER:
# if len(self._current_packet_type) < 2:
# self._current_packet_type.append(value)

# if len(self._current_packet_type) == 2:
# self._current_packet.accept_to_packet_type(
# self._current_packet_type)
# self._current_analysis_status = ANALYSIS_STATUS.FOUND_PACKET_TYPE
# self._read_index += 2

# continue

# if self._current_analysis_status == ANALYSIS_STATUS.FOUND_PACKET_TYPE:
# self._current_packet.accept_to_length(value)
# self._current_analysis_status = ANALYSIS_STATUS.FOUND_PAYLOAD_LENGTH
# self._read_index += 1
# continue

# if self._current_analysis_status == ANALYSIS_STATUS.FOUND_PAYLOAD_LENGTH:
# self._current_packet.accept_to_payload(value)
# self._read_index += 1
# if self._read_index == self._current_packet.payload_length + 2:
# # calculate crc
# crc_result = self._current_packet.check_crc()
# if not crc_result:
# self.reset()
# continue

# # crc valid
# self._current_analysis_status = ANALYSIS_STATUS.CRC_PASSED

# if self._current_analysis_status == ANALYSIS_STATUS.CRC_PASSED:
# #self.crc_passed_count += 1
# # packets.push(this._currentPacket);
# self._parse_message(self._current_packet)
# self.reset()

# continue

# def reset(self):
# self._current_analysis_status = ANALYSIS_STATUS.INIT
# self._sync_pattern = collections.deque(2*[0], 2)
# self._current_packet_type = []
# self._read_index = 0

# def _parse_message(self, data_packet):
# # parse interactive commands
# is_interactive_cmd = INPUT_PACKETS.__contains__(
# data_packet.packet_type)
# if is_interactive_cmd:
# self._parse_input_packet(data_packet)
# else:
# # consider as output packet, parse output Messages
# self._parse_output_packet(data_packet)

# def _parse_input_packet(self, data_packet):
# payload_parser = match_command_handler(data_packet.packet_type)
# if payload_parser:
# data, error = payload_parser(
# data_packet.payload, self.properties['userConfiguration'])

# self.emit('command',
# packet_type=data_packet.packet_type,
# data=data,
# error=error,
# raw=data_packet.raw)
# else:
# print('[Warning] Unsupported command {0}'.format(
# data_packet.packet_type))

# def _parse_output_packet(self, data_packet):
# # check if it is the valid out packet
# payload_parser = None
# is_other_output_packet = OTHER_OUTPUT_PACKETS.__contains__(
# data_packet.packet_type)
# if is_other_output_packet:
# payload_parser = other_output_parser
# data = payload_parser(data_packet.payload)
# return

# payload_parser = common_continuous_parser

# output_packet_config = next(
# (x for x in self.properties['userMessages']['outputPackets']
# if x['name'] == data_packet.packet_type), None)
# data = payload_parser(data_packet.payload, output_packet_config)

# if not data:
# return
# self.emit('continuous_message',
# packet_type=data_packet.packet_type,
# data=data,
# event_time=time.time())


class UartMessageParser(MessageParserBase):
def __init__(self, configuration):
super(UartMessageParser, self).__init__(configuration)
Expand Down Expand Up @@ -265,52 +140,7 @@ def analyse(self, data):
self.frame = list(self.sync_pattern)[:] # header_tp.copy()
self.find_header = True
#print(packet_type)
'''
for data_block in data:
if self.find_header:
self.frame.append(data_block)
if self.payload_len_idx == len(self.frame):
self.payload_len = data_block

elif 5 + self.payload_len + 2 == len(self.frame):
packet_type = ''.join(
["%c" % x for x in self.frame[PACKET_TYPE_INDEX:4]])
# self.find_header = False
result = helper.calc_crc(self.frame[2:-2])
if result[0] == self.frame[-2] and result[1] == self.frame[-1]:
if packet_type == 'gB':
print('parsed')
# find a whole frame
# self._parse_frame(self.frame, self.payload_len)
self._parse_message(
packet_type, self.payload_len, self.frame)
else:
APP_CONTEXT.get_logger().logger.info(
"crc check error! packet_type:{0}".format(packet_type))
print('crc',packet_type,'calc',result,'expect',self.frame[-2:])
self.emit('crc_failure', packet_type=packet_type,
event_time=time.time())
input_packet_config = next(
(x for x in self.properties['userMessages']['inputPackets']
if x['name'] == packet_type), None)
if input_packet_config:
self.emit('command',
packet_type=packet_type,
data=[],
error=True,
raw=self.frame)
self.find_header = False
self.payload_len = 0
self.sync_pattern = collections.deque(2*[0], 2)
self.frame=[]
else:
self.sync_pattern.append(data_block)
if operator.eq(list(self.sync_pattern), MSG_HEADER):
self.frame = MSG_HEADER[:] # header_tp.copy()
self.find_header = True
'''
def _parse_message(self, packet_type, payload_len, frame):
payload = frame[5:payload_len+5]
# parse interactive commands
Expand Down Expand Up @@ -355,6 +185,7 @@ def _parse_output_packet(self, packet_type, payload):
if not data:
# APP_CONTEXT.get_logger().logger.info(
# 'Cannot parse packet type {0}. It may caused by firmware upgrade'.format(packet_type))
#pass
return

self.emit('continuous_message',
Expand Down
Loading

0 comments on commit dab003f

Please sign in to comment.