Skip to content

Commit

Permalink
Add ttyACM detection
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-013 authored Dec 3, 2023
1 parent 14d8157 commit 1943f28
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
13 changes: 12 additions & 1 deletion sources/leddevice/dev_serial/EspTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EspTools
_rs232Port.write((char*)comBuffer, sizeof(comBuffer));
}

static void initializeEsp(QSerialPort& _rs232Port, QSerialPortInfo& serialPortInfo, Logger*& _log)
static void initializeEsp(QSerialPort& _rs232Port, QSerialPortInfo& serialPortInfo, Logger*& _log, bool _forceSerialDetection)
{
uint8_t comBuffer[] = { 0x41, 0x77, 0x41, 0x2a, 0xa2, 0x15, 0x68, 0x79, 0x70, 0x65, 0x72, 0x68, 0x64, 0x72 };

Expand Down Expand Up @@ -75,6 +75,17 @@ class EspTools
_rs232Port.setRequestToSend(true);
_rs232Port.setRequestToSend(false);
}
else if (!serialPortInfo.hasProductIdentifier() && !serialPortInfo.hasVendorIdentifier() && _forceSerialDetection)
{
Warning(_log, "Force ESP/Pico detection override enabled. HyperHDR skips the reset. State: %i, %i",
_rs232Port.isDataTerminalReady(), _rs232Port.isRequestToSend());

_rs232Port.write((char*)comBuffer, sizeof(comBuffer));

_rs232Port.setDataTerminalReady(true);
_rs232Port.setRequestToSend(true);
_rs232Port.setRequestToSend(false);
}
else
{
// reset to defaults
Expand Down
5 changes: 4 additions & 1 deletion sources/leddevice/dev_serial/ProviderRs232.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ ProviderRs232::ProviderRs232(const QJsonObject& deviceConfig)
, _delayAfterConnect_ms(0)
, _frameDropCounter(0)
, _espHandshake(true)
, _forceSerialDetection(true)
{
}

Expand All @@ -58,11 +59,13 @@ bool ProviderRs232::init(const QJsonObject& deviceConfig)
_delayAfterConnect_ms = deviceConfig["delayAfterConnect"].toInt(0);
_espHandshake = deviceConfig["espHandshake"].toBool(false);
_maxRetry = _devConfig["maxRetry"].toInt(60);
_forceSerialDetection = deviceConfig["forceSerialDetection"].toBool(false);

Debug(_log, "Device name : %s", QSTRING_CSTR(_deviceName));
Debug(_log, "Auto selection: %d", _isAutoDeviceName);
Debug(_log, "Baud rate : %d", _baudRate_Hz);
Debug(_log, "ESP handshake : %s", (_espHandshake) ? "ON" : "OFF");
Debug(_log, "Force ESP/Pico Detection : %s", (_forceSerialDetection) ? "ON" : "OFF");
Debug(_log, "Delayed open : %d", _delayAfterConnect_ms);
Debug(_log, "Retry limit : %d", _maxRetry);

Expand Down Expand Up @@ -246,7 +249,7 @@ bool ProviderRs232::tryOpen(int delayAfterConnect_ms)
{
disconnect(&_rs232Port, &QSerialPort::readyRead, nullptr, nullptr);

EspTools::initializeEsp(_rs232Port, serialPortInfo, _log);
EspTools::initializeEsp(_rs232Port, serialPortInfo, _log, _forceSerialDetection);
}
}
else
Expand Down
2 changes: 2 additions & 0 deletions sources/leddevice/dev_serial/ProviderRs232.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public slots:
int _frameDropCounter;

bool _espHandshake;

bool _forceSerialDetection;
};

#endif // PROVIDERRS232_H
31 changes: 23 additions & 8 deletions sources/leddevice/schemas/schema-adalight.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@
},
"propertyOrder" : 4
},
"forceSerialDetection" :
{

"type" : "boolean",
"format": "checkbox",
"title" : "edt_dev_spec_forceSerialDetection",
"default" : false,
"required" : true,
"options": {
"dependencies": {
"awa_mode": true
}
},
"propertyOrder" : 5
},
"white_channel_calibration": {
"type": "boolean",
"format": "checkbox",
Expand All @@ -46,7 +61,7 @@
"awa_mode": true
}
},
"propertyOrder" : 5
"propertyOrder" : 6
},
"white_channel_limit": {
"type": "number",
Expand All @@ -63,7 +78,7 @@
"white_channel_calibration": true
}
},
"propertyOrder" : 6
"propertyOrder" : 7
},
"white_channel_red": {
"type": "integer",
Expand All @@ -79,7 +94,7 @@
"white_channel_calibration": true
}
},
"propertyOrder" : 7
"propertyOrder" : 8
},
"white_channel_green": {
"type": "integer",
Expand All @@ -95,7 +110,7 @@
"white_channel_calibration": true
}
},
"propertyOrder" : 8
"propertyOrder" : 9
},
"white_channel_blue": {
"type": "integer",
Expand All @@ -111,7 +126,7 @@
"white_channel_calibration": true
}
},
"propertyOrder" : 9
"propertyOrder" : 10
},
"delayAfterConnect": {
"type": "integer",
Expand All @@ -124,7 +139,7 @@
"awa_mode": false
}
},
"propertyOrder" : 10
"propertyOrder" : 11
},
"lightberry_apa102_mode": {
"type": "boolean",
Expand All @@ -137,7 +152,7 @@
"awa_mode": false
}
},
"propertyOrder" : 11
"propertyOrder" : 12
},
"maxRetry":
{
Expand All @@ -149,7 +164,7 @@
"maximum" : 120,
"default" : 0,
"required" : true,
"propertyOrder" : 12
"propertyOrder" : 13
}
},
"additionalProperties": true
Expand Down
1 change: 1 addition & 0 deletions www/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1199,6 +1199,7 @@
"edt_serial_espHandshake" : "Esp8266/ESP32/Rp2040 handshake (<a href='https://github.com/awawa-dev/HyperHDR/wiki/HyperSerial' style='color:red'>info</a>)",
"edt_rpi_ws281x_driver" : "This driver is intended for advanced users and is <b>not recommended or supported</b> by the HyperHDR team. Please read the project FAQ section for reasons and don't ask us for help if you try to use it because it <b>revokes any support for your entire HyperHDR configuration</b>. Choose a better solution like HyperSerialEsp8266/HyperSerialESP32 (<a href='https://github.com/awawa-dev/HyperHDR/wiki/HyperSerial' style='color:red'>about</a>) or HyperSPI (<a href='https://github.com/awawa-dev/HyperSPI' style='color:red'>about</a>).",
"edt_dev_spec_awa_mode_title": "High speed serial AWA protocol with data integrity check (<a href='https://github.com/awawa-dev/HyperHDR/wiki/HyperSerial' style='color:red'>info</a>)",
"edt_dev_spec_forceSerialDetection": "Force ttyACM detection (for webOS: if serial port info returns empty)",
"led_editor_context_identify": "Identify",
"main_menu_grabber_lut" : "Download LUT",
"main_menu_grabber_lut_title" : "Custom LUT for USB grabber",
Expand Down

0 comments on commit 1943f28

Please sign in to comment.