Created
February 19, 2018 18:13
-
-
Save kulia/f2eb3ce40e17a53d43bbde5ab0ed582a to your computer and use it in GitHub Desktop.
Parser for streaming data from Xethru X4M300 presence sensor from Novelda.
This file contains hidden or 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
from pymoduleconnector import ModuleConnector | |
from pymoduleconnector.ids import XTID_SM_STOP | |
from pymoduleconnector.ids import XTS_ID_APP_PRESENCE_2 | |
from pymoduleconnector.ids import XTS_ID_PRESENCE_SINGLE | |
from pymoduleconnector.ids import XTS_ID_BASEBAND_IQ | |
from pymoduleconnector.ids import XTID_SM_RUN | |
import numpy as np | |
class StreamData: | |
sampling_frequency = 17 # frames per second | |
def __init__(self, usb_port): | |
''' | |
Parser for streaming data from Xethru X4M300 presence sensor from Novelda. | |
Download drivers from https://www.xethru.com/community/resources/ | |
:param usb_port: String | |
''' | |
self.usb_port = usb_port | |
self.mc = ModuleConnector(usb_port) | |
self.x4m300 = self.mc.get_x4m300() | |
self.x4m300.set_sensor_mode(XTID_SM_STOP, 0) | |
self.x4m300.load_profile(XTS_ID_APP_PRESENCE_2) | |
self.x4m300.set_output_control(XTS_ID_PRESENCE_SINGLE, 1) | |
self.x4m300.set_output_control(XTS_ID_BASEBAND_IQ, 1) | |
self.x4m300.set_sensor_mode(XTID_SM_RUN, 0) | |
def __iter__(self): | |
while True: | |
yield self.read_sensor() | |
def read_sensor(self): | |
''' | |
Read data from sensor | |
:return: | |
''' | |
messege = self.x4m300.read_message_baseband_iq() | |
i_data = [] | |
q_data = [] | |
for data in messege.i_data: | |
i_data = np.append(i_data, data) | |
for data in messege.q_data: | |
q_data = np.append(q_data, data) | |
return (i_data, q_data) | |
if __name__ == '__main__': | |
from secrets import USB_PORT | |
sd = StreamData(USB_PORT) | |
for i_data, q_data in sd: | |
print('i_data:', i_data) | |
print('q_data:', q_data) |
Hi @Prisila20 ,
Thanks for your interest in the script! For the pymoduleconnector module, I believe it can be accessed from this link: https://github.com/novelda/Legacy-SW/tree/master/ModuleConnector
However, I should mention that I haven't verified this source recently. This appears to be in Novelda's legacy software repository, so it should contain what you need for the X4M300.
Hi @kulia
Thank you so much.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @kulia
Thank you so much for sharing the Python parsing script for the X4M300 – it's been incredibly helpful!
Could you kindly share the pymoduleconnector module as well? I've been trying to locate it, but I haven’t been able to find a working source or download link from the Novelda website.
Your help would be greatly appreciated. Thanks again for your contribution!