Hello
I want to send an array of data (float ) from Matlab over USB.
I already implemented a virtual serial port using the AN00124: USB CDC Class as Virtual Serial Port. It´s working and the virtual port is created. But unfortunately, i don´t know how to send or recieve data over usb and stores them . Note that i managed to send Data from Matlab, the problem is that i don´t know how the procedure to receive them on the xmos.
Has anyone faced the sames issues and can maybe help me ?
Thanks
Regards
Tom
How to receive an array of data from Matlab over usb ?
-
- Member
- Posts: 14
- Joined: Mon Jun 19, 2023 9:32 pm
-
- XCore Expert
- Posts: 897
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
In that application note the function app_virtual_com() simply loops back anything sent from the host back to the host. So I guess you need to modify this function to handle the data as you wish. I guess modifying it to interpret the data as floats and simply printing them would be a good start?
-
- Member
- Posts: 14
- Joined: Mon Jun 19, 2023 9:32 pm
Hello
Thank you for your answer
Do yo have any idea about how i can do that ? Sorry, i'm not the biggest expert on the subject.
Thank you for your answer
Do yo have any idea about how i can do that ? Sorry, i'm not the biggest expert on the subject.
-
- XCore Expert
- Posts: 897
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
I would modify the code to build up an array of chars size 4 then use the XC reinterpret cast to reinterpret that array as a float. This example code should help you:
To build:
To run on the sim:
Code: Select all
#include <stdio.h>
int main()
{
// 0.6 in float
char test[] = {0x9A, 0x99, 0x19, 0x3F};
// Re-interpret char array as float
float x = (test, float);
printf("%f\n", x);
}
Code: Select all
$ xcc test.xc -target=XCORE-AI-EXPLORER
Code: Select all
$ xsim a.xe
-
- Member
- Posts: 14
- Joined: Mon Jun 19, 2023 9:32 pm
Thank
I'll try and contact you again if i'm having troubles. If you don't mind of course
I'll try and contact you again if i'm having troubles. If you don't mind of course
-
- XCore Expert
- Posts: 897
- Joined: Thu Dec 10, 2009 9:20 pm
- Location: Bristol, UK
Tom, you sent me an email, please post it here. I don't reply to direct messages in general.