tanakamasayuki / LinxESP32

LINX - Digilent/LabVIEW MakerHub for ESP32
BSD 2-Clause "Simplified" License
23 stars 6 forks source link

Serial Connection #4

Open aydins03 opened 2 years ago

aydins03 commented 2 years ago

Thank you very much for your effort at creating such a great work.

I want to connect the ESP32 with a cable for the serial communication but the linx library giving connection error. The library working great for the Bluetooth or WiFi connection but couldn’t use it from the usb serial port. I have tried M5StickC and another ESP32 board from Wemos with all the channel pointers for Serial, Serial1 and Serial2 but the result did not change.

Is there anything you suggest that I can try

Best regards, Ahmet.

tanakamasayuki commented 2 years ago

Hello. What error message did you get?

#include "Vrekrer_scpi_parser.h"

SCPI_Parser scpi;

void setup() {
  Serial.begin(115200);
  delay(500);
  Serial.println();

  scpi.RegisterCommand("*IDN?", &Identify);
  scpi.RegisterCommand("TIME?", &Time);
  scpi.SetErrorHandler(&Error);
}

void loop() {
  scpi.ProcessInput(Serial, "\n");
  delay(1);
}

void Identify(SCPI_C commands, SCPI_P parameters, Stream& interface) {
  interface.println("Vrekrer,Arduino SCPI Dimmer,#00,v0.4.2");
}

void Time(SCPI_C commands, SCPI_P parameters, Stream& interface) {
  interface.println(millis());
}

void Error(SCPI_C commands, SCPI_P parameters, Stream& interface) {
}

I am currently studying the SCPI protocol. This may be simpler.

aydins03 commented 2 years ago

Error 5003:

Possible reason(s):

LabVIEW was unable to connect to the LINX device using the following settings:

Interface: Serial COM Port: COM4

This is the error.

The M5StickC is connected with a cable and the com port is COM4.

The port setting at your as follows:

LinxSerialConnection.Start(LinxDevice, 0);

This is all the code in case I am missing some libraries to include.

Thanks for your effort.

//Include Device Specific Header From Sketch>>Import Library (In This Case LinxESP32.h) //Also Include Desired LINX Listener From Sketch>>Import Library (In This Case LinxSerialListener.h)

include

include

//Create A Pointer To The LINX Device Object We Instantiate In Setup() LinxESP32* LinxDevice;

//Initialize LINX Device And Listener void setup() { //Instantiate The LINX Device LinxDevice = new LinxESP32();

// PWM & Servo Setup uint8_t pwmList[] = {}; // Max16Ch {0, 26, ...} uint16_t pwmFrequency = 12000; // LED:12000, Servo:50 for (int i = 0; i < sizeof(pwmList); i++) { ledcSetup(i, pwmFrequency, 8); pinMode(pwmList[i], OUTPUT); ledcAttachPin(pwmList[i], i); }

// I2C Begin ch0:Wire, ch1:Wire1 //Wire.begin(); //Wire1.begin(32, 33);

// The LINXT Listener Is Pre Instantiated, Call Start And Pass A Pointer To The LINX Device And The UART Channel To Listen On // ch0:Serial // ch1:Serial1 // ch2:Serial2 // ch3:SerialBT LinxSerialConnection.Start(LinxDevice, 0); }

void loop() { //Listen For New Packets From LabVIEW LinxSerialConnection.CheckForCommands();

//Your Code Here, But It will Slow Down The Connection With LabVIEW delay(1); }

tanakamasayuki commented 2 years ago

Is the serial monitor open in the Arduino IDE?