Go Down

Topic: SerialUSB object - how to receive data in PC (Read 1 time) previous topic - next topic



I am using Arduino Due, and I want to send a large amount of data to PC.
For the sake of higher data rates, I use SerialUSB object to send data over the Native USB port of the Due. In the product page of Due, It is mentioned that it sends the data over Native USB port supporting CDC serial communication.

In MATLAB, for example, what is the way to receive data?

If it is not possible to receive data in MATLAB, how can I do that in another programming environment, like C or Python?

(I know maybe it's a programming/software question and not an Arduino/Due question....)

Thanks in advance.


Sep 11, 2019, 05:39 pm Last Edit: Sep 11, 2019, 05:41 pm by Microzod_
When I get home I'll post the code I used to send data to Matlab with, I used DMA to fill a buffer to send over USB as 2 uint8_t and then made them into a uint16_t in Matlab, the DMA part I got from this forum.

In the meantime, in Matlab you communicate with the due like a ordinary COM port, in Windows at least, read up upon Matlab COM port communication, it's really easy.


Sep 11, 2019, 05:51 pm Last Edit: Sep 11, 2019, 05:53 pm by Microzod_
This is just a quick version of the code I used in Matlab:
Code: [Select]
s = serial('COM10');
set(s, 'DataBits', 8);
set(s, 'StopBits', 1);
set(s, 'BaudRate', 115200);
set(s, 'Parity', 'none');
set(s, 'InputBufferSize', 3000000);

b_data = fread(s, 3000000, 'uint8');
LSB = b_data(1:2:end);
MSB = b_data(2:2:end);
result = ((MSB .* 256) + LSB);

clear s;
clear b_data LSB MSB;

Go Up