You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I connect MKR 1010 to a Lidar with a OTG cable .MKR 1010 is USBHost , it can send command to Lidar and receive data from Lidar.
But the problem I meet is the data I receive is loss some bytes. The bellow is my code.
`#include <cdcacm.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <usbhub.h>
#include "pgmstrings.h"
// On SAMD boards where the native USB port is also the serial console, use
// Serial1 for the serial console. This applies to all SAMD boards except for
// Arduino Zero and M0 boards.
#if (USB_VID==0x2341 && defined(ARDUINO_SAMD_ZERO)) || (USB_VID==0x2a03 && defined(ARDUINO_SAM_ZERO))
#define SerialDebug SERIAL_PORT_MONITOR
#else
#define SerialDebug Serial1
#endif
class ACMAsyncOper : public CDCAsyncOper
{
public:
uint8_t OnInit(ACM *pacm);
};
I connect MKR 1010 to a Lidar with a OTG cable .MKR 1010 is USBHost , it can send command to Lidar and receive data from Lidar.
But the problem I meet is the data I receive is loss some bytes. The bellow is my code.
`#include <cdcacm.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <usbhub.h>
#include "pgmstrings.h"
// On SAMD boards where the native USB port is also the serial console, use
// Serial1 for the serial console. This applies to all SAMD boards except for
// Arduino Zero and M0 boards.
#if (USB_VID==0x2341 && defined(ARDUINO_SAMD_ZERO)) || (USB_VID==0x2a03 && defined(ARDUINO_SAM_ZERO))
#define SerialDebug SERIAL_PORT_MONITOR
#else
#define SerialDebug Serial1
#endif
class ACMAsyncOper : public CDCAsyncOper
{
public:
uint8_t OnInit(ACM *pacm);
};
uint8_t ACMAsyncOper::OnInit(ACM *pacm)
{
uint8_t rcode;
// Set DTR = 1 RTS=1
rcode = pacm->SetControlLineState(3);
if (rcode)
{
ErrorMessage<uint8_t>(PSTR("SetControlLineState"), rcode);
return rcode;
}
LINE_CODING lc;
lc.dwDTERate = 115200;
lc.bCharFormat = 0;
lc.bParityType = 0;
lc.bDataBits = 8;
rcode = pacm->SetLineCoding(&lc);
if (rcode)
ErrorMessage<uint8_t>(PSTR("SetLineCoding"), rcode);
return rcode;
}
uint8_t* hokuyo_data= (uint8_t*) malloc(128);
char ssid[] = "passssss";
char pass[] = "12345678";
int keIndex = 0;
int status = WL_IDLE_STATUS;
const IPAddress serverIP(192, 168, 137, 1);
uint16_t serverPort = 54768;
WiFiClient client;
USBHost UsbH;
USBHub Hub(&UsbH);
ACMAsyncOper AsyncOper;
ACM Acm(&UsbH, &AsyncOper);
void setup()
{
// SerialDebug.begin(19200);
// SerialDebug.println("Start");
if (UsbH.Init())
//SerialDebug.println("USB host failed to initialize");
//SerialDebug.println("USB Host init OK");
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
//Serial.print(".");
}
if (client.connect(serverIP, serverPort))
{
client.print("Hello world!");
}
{
client.stop();
}
//client.connect(serverIP, serverPort);
//client.print("Hello world!");
}
void loop()
{
}`
The text was updated successfully, but these errors were encountered: