Hi
I have a python script that read IMU data from the sensor. This is the part of the scrip which get the IMU sensor data
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
import Microcontroller_Manager_Serial as Serial
## Function which get measurement from the IMU sensor
def IMU_Get_Values(communication_mode,choice):
data_out = [83, 58, choice, 58, 13, 10]
data_in = [48]
current_data_size = 30
current_time_out = 0.5
if (communication_mode == 2):
Bluetooth.Bluetooth_Send_Data(bytes(data_out))
data_in = Bluetooth.Bluetooth_Receive_Data(current_data_size,current_time_out)
else:
Serial.Serial_Port_Send_Data(data_out)
data_in = Serial.Serial_Port_Receive_Data(current_data_size,current_time_out)
return data_in
|
Now from that python Script I need a C++ code that can ask for IMU data update and publish it. This is my C++ code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#include <stdio.h>
#include <string.h>
#include <wiringSerial.h>
export module Microcontroller_Manager_Serial.Serial;
//import Microcontroller_Manager_Bluetooth as Bluetooth
//Communication_Mode_ = 0
int Communication_Mode_ = 0;
double data_recieved=0;
int main()
{
int serial_port = serialOpen ("/dev/serial0", 115200);
if (serial_port > 0 ) {
//double data_recieved;
data_recieved = IMU.IMU_Get_Values(1, 1)
print(colored("Raw data received: ", 'red'), data_received)
}
}
|
But when compile it I got the following errors:
get_data_test.cpp:21:41: warning: multi-character character constant [-Wmultichar]
print(colored("Raw data received: ", 'red'), data_received)
^~~~~
get_data_test.cpp:5:1: warning: keyword ‘export’ not implemented, and will be ignored
export module Microcontroller_Manager_Serial.Serial;
^~~~~~
get_data_test.cpp:5:8: error: ‘module’ does not name a type; did you mean ‘double’?
export module Microcontroller_Manager_Serial.Serial;
^~~~~~
double
get_data_test.cpp: In function ‘int main()’:
get_data_test.cpp:20:20: error: ‘IMU’ was not declared in this scope
data_recieved = IMU.IMU_Get_Values(1, 1)
Any help?