Skip to content

Commit

Permalink
release: 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yiweisong committed Oct 11, 2021
2 parents 72de35d + 78db6ff commit 5cb6d35
Show file tree
Hide file tree
Showing 70 changed files with 6,354 additions and 5,084 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ dist
aceinna.ico
.pytest_cache
loggers/
/backup
/backup
/libs
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# History

---
## 2.6.0 / 2021-10-11
- [INS401] Support communication with ethernet 100base-t1 protocol.

## 2.5.0 / 2021-07-02
- [DMU] Support firmware upgrade.
- [OpenRTK/RTK330LA] Support ST9100 chip upgrade.
Expand Down
61 changes: 47 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,24 @@ A message communication tool for OpenIMU, OpenRTK and other devices of Aceinna
## Steps

### 1. Start the tool
There are 2 ways to run the tool
There are 3 ways to run the tool

#### Prepare
Install the dependency library. It is better to create a virtual environment before to do it.
1. Install the dependency library. It is better to create a virtual environment before to do it.

python 3.x
```bash
$ pip install -r requirements.txt
```

2. Install pcap api library(`optional`). Because we try to support INS401 a new device from Aceinna. It would use 100BASE-T1 ethernet, and the data transfer is in low-level of network, so we need help of pcap api. Actually, we integrated `scapy` in our project. The pcap api library is the dependency of `scapy`. If you are using a INS401 device, please also install the library based on your platform.

| Platform | Libraray | Reference |
| - | - | - |
| Windows | `npcap` | https://scapy.readthedocs.io/en/latest/installation.html#windows |
| Ubuntu | `tcpdump` | https://scapy.readthedocs.io/en/latest/installation.html#debian-ubuntu-fedora |
| Mac | `libpcap` | https://scapy.readthedocs.io/en/latest/installation.html#mac-os-x |


#### A. From source code

##### Run
Expand All @@ -35,19 +43,31 @@ $ pyinstaller build.spec
```

##### Run
```
```bash
$ cd dist
$ ./ans-devices
```

##### Startup Arguments
#### C. From pip

##### Install
```bash
$ pip install openimu
```

##### Run
```
$ openimu
```

#### Startup Arguments
You can specify some arguments while run the tool

Arguments:

| Name | Type | Default | Description |
| - | :-: | :-: | - |
| -i, --interface | String | 'default' | Value should be `uart`, `eth` |
| -i, --interface | String | 'default' | Value should be `uart`, `eth`, `100base-t1` |
| -p, --port | Number | '8000' | Value should be an available port |
| --device-type | String | 'auto' | Value should be one of `IMU`, `RTK`, `DMU` |
| -b, --baudrate | String | None | Value should be a valid baudrate. The valid value should be one of `38400`, `57600`, `115200`, `230400`, `460800` |
Expand Down Expand Up @@ -141,24 +161,37 @@ Aceinna Device could be connected with your PC via UART or LAN. The supported in
| OpenIMU | `uart` | |
| OpenRTK | `uart`, `eth` | The startup argument `-i eth` is supported |
| RTK330L | `uart` | |
| INS401 | `100base-t1` | The startup argument `-i 100base-t1` is supported |


## Parse Tool
There is a log parse tool integrated in. It could parse OpenRTK and RTK330LA log from data folder. Assgin `parse` to start it.

Example
```bash
$ ans-devices parse
```
There is a log parse tool integrated in. It could parse `OpenRTK`, `RTK330LA`, `IN S401` raw data log from data folder. Assgin `parse` to start it.

Arguments:
### Arguments:

| Name | Type | Default | Description |
| - | :-: | :-: | - |
| -t | String | 'openrtk' | Switch work mode. Value should be one of `openrtk`,`rtkl` |
| -t | String | 'openrtk' | Switch work mode. Value should be one of `openrtk`,`rtkl`,`ins401` |
| -p | String | '.' | Value should be a valid path. It could be the container folder of log files |
| -i | Number | 5 | INS kml rate(hz) |

### Example

Run from source code
```bash
$ python main.py parse
```

Work as execution file
```bash
$ ans-devices parse
```

Run from pip
```bash
$ openimu parse
```

## Changelogs and Release Notes

Please refer to [HISTORY.md](HISTORY.md "Change History")
2 changes: 1 addition & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ parameters:

| Name | Type | Default | Description |
| - | :-: | :-: | - |
| -i, --interface | String | 'default' | Value should be `uart`, `eth`. Depends on device type |
| -i, --interface | String | 'default' | Value should be `uart`, `eth`, `100base-t1`. Depends on device type |
| -p, --port | Number | '8000' | Value should be an available port |
| --device-type | String | 'auto' | Value should be `IMU`, `RTK`, `DMU` |
| -b, --baudrate | String | None | Value should be a valid baudrate. The valid value should be one of `38400`, `57600`, `115200`, `230400`, `460800` |
Expand Down
17 changes: 2 additions & 15 deletions build.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,12 @@ block_cipher = None
root_path = os.path.join(os.getcwd(),'src')

a = Analysis([os.path.join(root_path,'aceinna','executor.py'),
# os.path.join(os.getcwd(), 'src', 'bootstrap/base.py'),
# os.path.join(os.getcwd(), 'src', 'bootstrap/cli.py'),
# os.path.join(os.getcwd(), 'src', 'bootstrap/loader.py'),
# os.path.join(os.getcwd(), 'src', 'bootstrap/web.py'),
# os.path.join(os.getcwd(), 'src','devices', 'base/uart_base.py'),
# os.path.join(os.getcwd(), 'src','devices', 'configs/openimu_predefine.py'),
# os.path.join(os.getcwd(), 'src','devices', 'configs/openrtk_predefine.py'),
# os.path.join(os.getcwd(), 'src','devices', 'openimu/uart_provider.py'),
# os.path.join(os.getcwd(), 'src','devices', 'openrtk/uart_provider.py'),
# os.path.join(os.getcwd(), 'src','devices', 'device_manager.py'),
# os.path.join(os.getcwd(), 'src','framework', 'communicator.py'),
# os.path.join(os.getcwd(), 'src','framework', 'context.py'),
# os.path.join(os.getcwd(), 'src','framework', 'file_storage.py'),
# os.path.join(os.getcwd(), 'src','framework', 'utils/helper.py'),
],
pathex=[root_path],
binaries=[],
datas=[
(os.path.join(root_path,'aceinna','setting'), os.path.join('setting'))
(os.path.join(root_path,'aceinna','setting'), os.path.join('setting')),
(os.path.join(root_path,'aceinna','libs'), os.path.join('libs'))
],
hiddenimports=[],
hookspath=[],
Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ azure-common==1.1.24
azure-storage-blob==2.1.0
azure-storage-common==2.1.0
certifi==2019.11.28
cffi==1.13.2
cffi==1.14.5
chardet==3.0.4
cryptography==3.3.2
idna==2.8
isodate==0.6.0
msrest==0.6.10
oauthlib==3.1.0
psutil==5.6.6
psutil==5.8.0
pycparser==2.19
pyserial==3.4
python-can==3.3.4
Expand All @@ -19,3 +19,4 @@ requests-oauthlib==1.3.0
six==1.13.0
tornado==6.0.3
urllib3==1.25.7
scapy==2.4.5
35 changes: 32 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,44 @@ def load_json_file_path_under_setting_folder():
json_file_paths = []
setting_root_path = os.path.join(os.getcwd(), 'src', 'aceinna', 'setting')
for root, dirs, files in os.walk(setting_root_path):
json_file = next((item for item in files if item.__contains__('.json')), None)
json_file = next(
(item for item in files if item.__contains__('.json')), None)
if not json_file:
continue

json_file_path = os.path.join(root.replace(setting_root_path,'setting'), json_file)
json_file_path = os.path.join(root.replace(
setting_root_path, 'setting'), json_file)
json_file_paths.append(json_file_path)

return json_file_paths


def load_libraries():
file_paths = []
setting_root_path = os.path.join(os.getcwd(), 'src', 'aceinna', 'libs')
for root, dirs, files in os.walk(setting_root_path):
for item in files:
lib_file = item if item.__contains__(
'.dll') or item.__contains__('.so') else None
if not lib_file:
continue

file_path = os.path.join(root.replace(
setting_root_path, 'libs'), lib_file)
file_paths.append(file_path)

return file_paths


def load_resources():
resources = []
json_files = load_json_file_path_under_setting_folder()
lib_files = load_libraries()
resources.extend(json_files)
resources.extend(lib_files)
return resources


PACKAGE_DESCRIPTION = "Aceinna Navigation System Open Devices Library"

INSTALL_REQUIRES = [
Expand All @@ -55,7 +84,7 @@ def load_json_file_path_under_setting_folder():
packages=find_packages("src", exclude=['test', 'tests']),
package_dir={"": "src"},
package_data={
'aceinna': load_json_file_path_under_setting_folder()
'aceinna': load_resources()
},
classifiers=[
"Environment :: Console",
Expand Down
2 changes: 1 addition & 1 deletion src/aceinna/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Package Version
VERSION = '2.5.0'
VERSION = '2.6.0'
PACKAGE_NAME = 'openimu'
71 changes: 56 additions & 15 deletions src/aceinna/bootstrap/log_parser.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,61 @@
import os
from ..tools.openrtk_parse import do_parse as do_parse_openrtk_logs
from ..tools.rtkl_parse import do_parse as do_parse_rtkl_logs
import sys
from ctypes import *
from ..models import LogParserArgs
from ..framework.constants import APP_TYPE
from ..framework.context import APP_CONTEXT
from ..framework.utils import resource


def prepare_lib_folder():
executor_path = resource.get_executor_path()
lib_folder_name = 'libs'

# copy contents of setting file under executor path
lib_folder_path = os.path.join(
executor_path, lib_folder_name)

if not os.path.isdir(lib_folder_path):
os.makedirs(lib_folder_path)

platform = sys.platform

if platform.startswith('win'):
lib_file = 'UserDecoderLib.dll'
if platform.startswith('linux'):
lib_file = 'UserDecoderLib_linux.so'
if platform.startswith('darwin'):
lib_file = 'UserDecoderLib_mac.so'

lib_path = os.path.join(lib_folder_path, lib_file)

if not os.path.isfile(lib_path):
lib_content = resource.get_content_from_bundle(
lib_folder_name, lib_file)
if lib_content is None:
raise ValueError('Lib file content is empty')

with open(lib_path, "wb") as code:
code.write(lib_content)

return lib_path


def do_parse(log_type, folder_path):
lib_path = prepare_lib_folder()

lib = CDLL(lib_path)
for root, _, file_name in os.walk(folder_path):
for fname in file_name:
if fname.startswith('user') and fname.endswith('.bin'):
file_path = os.path.join(folder_path, fname)
if log_type == 'openrtk':
lib.decode_openrtk_user(bytes(file_path, encoding='utf8'))
if log_type == 'rtkl':
lib.decode_openrtk_inceptio(bytes(file_path, encoding='utf8'))
if log_type == 'ins401':
lib.decode_ins401(bytes(file_path, encoding='utf8'))


class LogParser:
_options = None
Expand All @@ -19,23 +71,12 @@ def listen(self):
'''
self._validate_params()

setting_file = 'log-parser.json'

if self._options.log_type == 'openrtk':
do_parse_openrtk_logs(self._options.path,
self._options.kml_rate,
setting_file)
elif self._options.log_type == 'rtkl':
do_parse_rtkl_logs(self._options.path,
self._options.kml_rate,
setting_file)
else:
raise ValueError('No matched log parser')
do_parse(self._options.log_type, self._options.path)

os._exit(1)

def _validate_params(self):
for attr_name in ['log_type', 'path', 'kml_rate']:
for attr_name in ['log_type', 'path']:
attr_value = getattr(self._options, attr_name)
if not attr_value:
raise ValueError(
Expand Down
11 changes: 8 additions & 3 deletions src/aceinna/core/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,15 @@ def _handle_device_exception(self, error, message):
self._communicator.find_device(self._device_discover_handler)

def _handle_device_upgrade_restart(self):
self._communicator.set_find_options({
'com_port': self._communicator.serial_port.port,
find_options = {
'device_type': self._device_provider.type
})
}
if hasattr(self._communicator, 'serial_port'):
find_options['com_port'] = self._communicator.serial_port.port

if hasattr(self._communicator, 'set_find_options'):
self._communicator.set_find_options(find_options)

self._communicator.find_device(
self._device_upgrade_restart_handler,
retries=2,
Expand Down
2 changes: 2 additions & 0 deletions src/aceinna/core/gnss.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class RTCMParser(EventBase):
current_packet: RTCMPacket
found_header_count = 0
crc_passed_count = 0
crc_failed_count = 0

def __init__(self):
super(RTCMParser, self).__init__()
Expand Down Expand Up @@ -177,6 +178,7 @@ def _analysis(self):
if not crc_result:
self.current_analysis_status = ANALYSIS_STATUS.INIT
self.read_index = 0
self.crc_failed_count += 1
continue

# crc valid
Expand Down

0 comments on commit 5cb6d35

Please sign in to comment.