Hi, new here. I am trying to establish a Serial communication over USB-A port in the Portenta Machine Control. I came across this and this link like more or less what i am looking for. But which one i can use to make the communication/connection work. I have USB-TTL module with me, so i can test with this module whether some dummy data is transmitting(TX) or receiving(RX) with the help of noticing the led indication in the module. Also i tried to do establish the communication, did not work out.
arduino code
#include <mbed.h>
#include <USBSerial.h>
#include "greentea-client/test_env.h"
#define MSG_VALUE_DUMMY "0"
#define CDC_LOOPBACK_REPS 1200
#define SERIAL_LOOPBACK_REPS 100
#define MSG_KEY_PORT_OPEN_WAIT "port_open_wait"
#define USB_DEV_SN_LEN (32)
char usb_dev_sn[USB_DEV_SN_LEN + 1];
USBSerial cdc(true, 0x10c4, 0xea60, 0x0001);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
cdc.configured();
cdc.ready();
cdc.connect();
while(!cdc.configured()){
Serial.println("cdc not configured");
delay(1);
}
greentea_send_kv(MSG_KEY_PORT_OPEN_WAIT, MSG_VALUE_DUMMY);
cdc.wait_ready();
uint8_t rx_buff, tx_buff;
for(int i = 0; i < CDC_LOOPBACK_REPS; i++){
tx_buff = static_cast<uint8_t>(rand() % 0x100);
rx_buff = static_cast<uint8_t>(tx_buff + 1);
cdc.send(&tx_buff, 1);
Serial.println("Sending: %02X\n");
if (tx_buff < 0x10) Serial.print("0");
Serial.println(tx_buff, HEX);
cdc.receive(&rx_buff, 1, NULL);
assert(tx_buff== rx_buff);
Serial.print("Received: 0x");
if (rx_buff < 0x10) Serial.print("0");
Serial.println(rx_buff, HEX);
}
cdc.disconnect();
Serial.println("Hello world");
delay(1000);
}
Nothing happening, and nothing in the serial monitor. I am kinda lost. If someone help me with this, it will be so helpful. Thanks in Advance