-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
23,416 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import logging | ||
import struct | ||
import sys | ||
import time | ||
from pathlib import Path | ||
|
||
from umrx_app_v3.shuttle_board.bma456.bma456_shuttle import BMA456Shuttle | ||
|
||
|
||
def setup_logging(level: int = logging.DEBUG) -> logging.Logger: | ||
logger = logging.getLogger() | ||
logger.setLevel(level) | ||
stdout_handler = logging.StreamHandler(sys.stdout) | ||
log_format = "(%(asctime)s) [%(levelname)-8s] %(filename)s:%(lineno)d: %(message)s" | ||
log_formatter = logging.Formatter(log_format) | ||
stdout_handler.setFormatter(log_formatter) | ||
file_handler = logging.FileHandler(f"{Path(__file__).parent / Path(__file__).stem}.log", mode="w") | ||
file_handler.setFormatter(log_formatter) | ||
logger.addHandler(stdout_handler) | ||
logger.addHandler(file_handler) | ||
return logger | ||
|
||
|
||
if __name__ == "__main__": | ||
logger = setup_logging() | ||
shuttle = BMA456Shuttle.on_hardware_v3_rev1() | ||
shuttle.initialize() | ||
shuttle.check_connected_hw() | ||
shuttle.configure_i2c() | ||
logger.info(f"chip_id=0x{shuttle.sensor.chip_id:02X}") | ||
assert shuttle.sensor.chip_id == 0x16 | ||
shuttle.sensor.pwr_conf = 0x00 | ||
shuttle.sensor.init_ctrl = 0x00 | ||
shuttle.write_mm_config_file() | ||
time.sleep(0.01) | ||
shuttle.sensor.init_ctrl = 0x01 | ||
shuttle.configure_interrupt_streaming() | ||
shuttle.start_streaming() | ||
time.sleep(0.1) | ||
logger.info("configuration complete, start streaming now") | ||
for idx in range(1000): | ||
for streaming in shuttle.board.receive_interrupt_streaming_multiple(includes_mcu_timestamp=False): | ||
sensor_id, packet, time_stamp, payload = streaming | ||
a_x, a_y, a_z, t_0, t_1, t_2 = struct.unpack("<hhhBBB", payload) | ||
sensor_time = ((t_2 << 16) | (t_1 << 8) | t_0) * 39.0625e-6 | ||
logger.info( | ||
f"[{idx=:03d}], acceleration(a_x={a_x:+5d}, a_y={a_y:+5d}, a_z={a_z:+5d}), " | ||
f"time_stamp(s)={sensor_time:.3f}" | ||
) | ||
time.sleep(0.05) | ||
shuttle.board.stop_interrupt_streaming() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import logging | ||
import struct | ||
import sys | ||
import time | ||
from pathlib import Path | ||
|
||
from umrx_app_v3.shuttle_board.bma456.bma456_shuttle import BMA456Shuttle | ||
|
||
|
||
def setup_logging(level: int = logging.DEBUG) -> logging.Logger: | ||
logger = logging.getLogger() | ||
logger.setLevel(level) | ||
stdout_handler = logging.StreamHandler(sys.stdout) | ||
log_format = "(%(asctime)s) [%(levelname)-8s] %(filename)s:%(lineno)d: %(message)s" | ||
log_formatter = logging.Formatter(log_format) | ||
stdout_handler.setFormatter(log_formatter) | ||
file_handler = logging.FileHandler(f"{Path(__file__).parent / Path(__file__).stem}.log", mode="w") | ||
file_handler.setFormatter(log_formatter) | ||
logger.addHandler(stdout_handler) | ||
logger.addHandler(file_handler) | ||
return logger | ||
|
||
|
||
if __name__ == "__main__": | ||
logger = setup_logging() | ||
shuttle = BMA456Shuttle.on_hardware_v3_rev1() | ||
shuttle.initialize() | ||
shuttle.check_connected_hw() | ||
|
||
shuttle.configure_i2c() | ||
logger.info(f"chip_id=0x{shuttle.sensor.chip_id:04X}") | ||
assert shuttle.sensor.chip_id == 0x16 | ||
shuttle.sensor.pwr_conf = 0x00 | ||
shuttle.sensor.init_ctrl = 0x00 | ||
shuttle.write_mm_config_file() | ||
time.sleep(0.01) | ||
shuttle.sensor.init_ctrl = 0x01 | ||
shuttle.configure_polling_streaming() | ||
shuttle.start_streaming() | ||
time.sleep(0.1) | ||
for idx in range(1000): | ||
for streaming in shuttle.board.receive_polling_streaming_multiple(): | ||
sensor_id, payload = streaming | ||
a_x, a_y, a_z, t_0, t_1, t_2 = struct.unpack("<hhhBBB", payload) | ||
sensor_time = ((t_2 << 16) | (t_1 << 8) | t_0) * 39.0625e-6 | ||
logger.info( | ||
f"[{idx=:03d}], acceleration(a_x={a_x:+5d}, a_y={a_y:+5d}, a_z={a_z:+5d}), " | ||
f"time_stamp(s)={sensor_time:.3f}" | ||
) | ||
time.sleep(0.05) | ||
shuttle.board.stop_polling_streaming() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
import sys | ||
import time | ||
from pathlib import Path | ||
|
||
from umrx_app_v3.shuttle_board.bma456.bma456_shuttle import BMA456Shuttle | ||
|
||
|
||
def setup_logging(level: int = logging.DEBUG) -> logging.Logger: | ||
logger = logging.getLogger() | ||
logger.setLevel(level) | ||
stdout_handler = logging.StreamHandler(sys.stdout) | ||
log_format = "(%(asctime)s) [%(levelname)-8s] %(filename)s:%(lineno)d: %(message)s" | ||
log_formatter = logging.Formatter(log_format) | ||
stdout_handler.setFormatter(log_formatter) | ||
file_handler = logging.FileHandler(f"{Path(__file__).parent / Path(__file__).stem}.log", mode="w") | ||
file_handler.setFormatter(log_formatter) | ||
logger.addHandler(stdout_handler) | ||
logger.addHandler(file_handler) | ||
return logger | ||
|
||
|
||
if __name__ == "__main__": | ||
logger = setup_logging() | ||
shuttle = BMA456Shuttle.on_hardware_v3_rev1() | ||
shuttle.initialize() | ||
shuttle.check_connected_hw() | ||
|
||
shuttle.configure_i2c() | ||
|
||
logger.info(f"chip_id=0x{shuttle.sensor.chip_id:02X}") | ||
logger.info(f"err_reg=0x{shuttle.sensor.err_reg:02X}") | ||
logger.info(f"status=0x{shuttle.sensor.status:02X}") | ||
logger.info(f"pwr_conf=0x{shuttle.sensor.pwr_conf:02X}") | ||
|
||
logger.info(f"acceleration={shuttle.sensor.acc_data}") | ||
logger.info(f"sensor_time={shuttle.sensor.sensor_time}") | ||
logger.info(f"internal_status={shuttle.sensor.internal_status}") | ||
shuttle.sensor.pwr_conf = 0x00 | ||
shuttle.sensor.init_ctrl = 0x00 | ||
shuttle.write_mm_config_file() | ||
time.sleep(0.01) | ||
shuttle.sensor.init_ctrl = 0x01 | ||
shuttle.switch_on_accel() | ||
time.sleep(0.05) | ||
logger.info(f"internal_status={shuttle.sensor.internal_status}") | ||
logger.info(f"acceleration={shuttle.sensor.acc_data}") | ||
logger.info(f"sensor_time={shuttle.sensor.sensor_time}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import logging | ||
import struct | ||
import sys | ||
import time | ||
from pathlib import Path | ||
|
||
from umrx_app_v3.shuttle_board.bma456.bma456_shuttle import BMA456Shuttle | ||
|
||
|
||
def setup_logging(level: int = logging.DEBUG) -> logging.Logger: | ||
logger = logging.getLogger() | ||
logger.setLevel(level) | ||
stdout_handler = logging.StreamHandler(sys.stdout) | ||
log_format = "(%(asctime)s) [%(levelname)-8s] %(filename)s:%(lineno)d: %(message)s" | ||
log_formatter = logging.Formatter(log_format) | ||
stdout_handler.setFormatter(log_formatter) | ||
file_handler = logging.FileHandler(f"{Path(__file__).parent / Path(__file__).stem}.log", mode="w") | ||
file_handler.setFormatter(log_formatter) | ||
logger.addHandler(stdout_handler) | ||
logger.addHandler(file_handler) | ||
return logger | ||
|
||
|
||
if __name__ == "__main__": | ||
logger = setup_logging() | ||
shuttle = BMA456Shuttle.on_hardware_v3_rev1() | ||
shuttle.initialize() | ||
shuttle.check_connected_hw() | ||
|
||
shuttle.configure_spi() | ||
_ = shuttle.board.read_spi(shuttle.CS, 0, 1) # dummy read is required, do not delete | ||
|
||
logger.info(f"chip_id=0x{shuttle.sensor.chip_id:02X}") | ||
assert shuttle.sensor.chip_id == 0x16 | ||
shuttle.sensor.pwr_conf = 0x00 | ||
shuttle.sensor.init_ctrl = 0x00 | ||
shuttle.write_mm_config_file() | ||
time.sleep(0.01) | ||
shuttle.sensor.init_ctrl = 0x01 | ||
shuttle.configure_interrupt_streaming() | ||
shuttle.start_streaming() | ||
time.sleep(0.1) | ||
for idx in range(1000): | ||
for streaming in shuttle.board.receive_interrupt_streaming_multiple(includes_mcu_timestamp=False): | ||
sensor_id, packet, time_stamp, payload = streaming | ||
a_x, a_y, a_z, t_0, t_1, t_2 = struct.unpack("<xhhhBBB", payload) | ||
sensor_time = ((t_2 << 16) | (t_1 << 8) | t_0) * 39.0625e-6 | ||
logger.info( | ||
f"[{idx=:03d}], acceleration(a_x={a_x:+5d}, a_y={a_y:+5d}, a_z={a_z:+5d}), " | ||
f"time_stamp(s)={sensor_time:.3f}" | ||
) | ||
time.sleep(0.05) | ||
shuttle.board.stop_interrupt_streaming() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import logging | ||
import struct | ||
import sys | ||
import time | ||
from pathlib import Path | ||
|
||
from umrx_app_v3.shuttle_board.bma456.bma456_shuttle import BMA456Shuttle | ||
|
||
|
||
def setup_logging(level: int = logging.DEBUG) -> logging.Logger: | ||
logger = logging.getLogger() | ||
logger.setLevel(level) | ||
stdout_handler = logging.StreamHandler(sys.stdout) | ||
log_format = "(%(asctime)s) [%(levelname)-8s] %(filename)s:%(lineno)d: %(message)s" | ||
log_formatter = logging.Formatter(log_format) | ||
stdout_handler.setFormatter(log_formatter) | ||
file_handler = logging.FileHandler(f"{Path(__file__).parent / Path(__file__).stem}.log", mode="w") | ||
file_handler.setFormatter(log_formatter) | ||
logger.addHandler(stdout_handler) | ||
logger.addHandler(file_handler) | ||
return logger | ||
|
||
|
||
if __name__ == "__main__": | ||
logger = setup_logging() | ||
shuttle = BMA456Shuttle.on_hardware_v3_rev1() | ||
shuttle.initialize() | ||
shuttle.check_connected_hw() | ||
|
||
shuttle.configure_spi() | ||
_ = shuttle.board.read_spi(shuttle.CS, 0, 1) # dummy read is required, do not delete | ||
|
||
logger.info(f"chip_id=0x{shuttle.sensor.chip_id:02X}") | ||
assert shuttle.sensor.chip_id == 0x16 | ||
shuttle.sensor.pwr_conf = 0x00 | ||
shuttle.sensor.init_ctrl = 0x00 | ||
shuttle.write_mm_config_file() | ||
time.sleep(0.01) | ||
shuttle.sensor.init_ctrl = 0x01 | ||
shuttle.configure_polling_streaming() | ||
shuttle.start_streaming() | ||
time.sleep(0.1) | ||
for idx in range(1000): | ||
for streaming in shuttle.board.receive_polling_streaming_multiple(): | ||
sensor_id, payload = streaming | ||
a_x, a_y, a_z, t_0, t_1, t_2 = struct.unpack("<xhhhBBB", payload) | ||
sensor_time = ((t_2 << 16) | (t_1 << 8) | t_0) * 39.0625e-6 | ||
logger.info( | ||
f"[{idx=:03d}], acceleration(a_x={a_x:4d}, a_y={a_y:4d}, a_z={a_z:4d}), " | ||
f"time_stamp(s)={sensor_time:.3f}" | ||
) | ||
time.sleep(0.05) | ||
shuttle.board.stop_polling_streaming() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import logging | ||
import sys | ||
import time | ||
from pathlib import Path | ||
|
||
from umrx_app_v3.shuttle_board.bma456.bma456_shuttle import BMA456Shuttle | ||
|
||
|
||
def setup_logging(level: int = logging.DEBUG) -> logging.Logger: | ||
logger = logging.getLogger() | ||
logger.setLevel(level) | ||
stdout_handler = logging.StreamHandler(sys.stdout) | ||
log_format = "(%(asctime)s) [%(levelname)-8s] %(filename)s:%(lineno)d: %(message)s" | ||
log_formatter = logging.Formatter(log_format) | ||
stdout_handler.setFormatter(log_formatter) | ||
file_handler = logging.FileHandler(f"{Path(__file__).parent / Path(__file__).stem}.log", mode="w") | ||
file_handler.setFormatter(log_formatter) | ||
logger.addHandler(stdout_handler) | ||
logger.addHandler(file_handler) | ||
return logger | ||
|
||
|
||
if __name__ == "__main__": | ||
logger = setup_logging() | ||
shuttle = BMA456Shuttle.on_hardware_v3_rev1() | ||
shuttle.initialize() | ||
shuttle.check_connected_hw() | ||
|
||
shuttle.configure_spi() | ||
_ = shuttle.board.read_spi(shuttle.CS, 0, 1) # dummy read is required, do not delete | ||
|
||
logger.info(f"chip_id=0x{shuttle.sensor.chip_id:02X}") | ||
logger.info(f"err_reg=0x{shuttle.sensor.err_reg:02X}") | ||
logger.info(f"status=0x{shuttle.sensor.status:02X}") | ||
logger.info(f"pwr_conf=0x{shuttle.sensor.pwr_conf:02X}") | ||
|
||
logger.info(f"acceleration={shuttle.sensor.acc_data}") | ||
logger.info(f"sensor_time={shuttle.sensor.sensor_time}") | ||
logger.info(f"internal_status={shuttle.sensor.internal_status}") | ||
shuttle.sensor.pwr_conf = 0x00 | ||
shuttle.sensor.init_ctrl = 0x00 | ||
shuttle.write_mm_config_file() | ||
time.sleep(0.01) | ||
shuttle.sensor.init_ctrl = 0x01 | ||
shuttle.switch_on_accel() | ||
time.sleep(0.05) | ||
logger.info(f"internal_status={shuttle.sensor.internal_status}") | ||
logger.info(f"acceleration={shuttle.sensor.acc_data}") | ||
logger.info(f"sensor_time={shuttle.sensor.sensor_time}") |
Oops, something went wrong.