mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
cosemtic changes
This commit is contained in:
28
src/ems.cpp
28
src/ems.cpp
@@ -550,6 +550,15 @@ void _ems_sendTelegram() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we're preventing all outbound traffic, quit
|
||||||
|
if (EMS_Sys_Status.emsTxDisabled) {
|
||||||
|
EMS_TxQueue.shift(); // remove from queue
|
||||||
|
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
|
||||||
|
myDebug_P(PSTR("in Listen Mode. All Tx is disabled."));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get the first in the queue, which is at the head
|
// get the first in the queue, which is at the head
|
||||||
// we don't remove from the queue yet
|
// we don't remove from the queue yet
|
||||||
_EMS_TxTelegram EMS_TxTelegram = EMS_TxQueue.first();
|
_EMS_TxTelegram EMS_TxTelegram = EMS_TxQueue.first();
|
||||||
@@ -561,19 +570,18 @@ void _ems_sendTelegram() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we're in raw mode just fire and forget
|
// if we're in raw mode just fire and forget
|
||||||
// e.g. send 0B 88 02 00 20
|
|
||||||
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_RAW) {
|
if (EMS_TxTelegram.action == EMS_TX_TELEGRAM_RAW) {
|
||||||
_EMS_RxTelegram EMS_RxTelegram; // create new Rx object
|
|
||||||
|
|
||||||
EMS_TxTelegram.data[EMS_TxTelegram.length - 1] = _crcCalculator(EMS_TxTelegram.data, EMS_TxTelegram.length); // add the CRC
|
|
||||||
EMS_RxTelegram.length = EMS_TxTelegram.length; // full length of telegram
|
|
||||||
EMS_RxTelegram.telegram = EMS_TxTelegram.data;
|
|
||||||
EMS_RxTelegram.timestamp = millis(); // now
|
|
||||||
if (EMS_Sys_Status.emsLogging != EMS_SYS_LOGGING_NONE) {
|
if (EMS_Sys_Status.emsLogging != EMS_SYS_LOGGING_NONE) {
|
||||||
|
_EMS_RxTelegram EMS_RxTelegram; // create new Rx object
|
||||||
|
EMS_RxTelegram.length = EMS_TxTelegram.length; // full length of telegram
|
||||||
|
EMS_RxTelegram.telegram = EMS_TxTelegram.data;
|
||||||
|
EMS_RxTelegram.timestamp = millis(); // now
|
||||||
_debugPrintTelegram("Sending raw: ", &EMS_RxTelegram, COLOR_CYAN, true);
|
_debugPrintTelegram("Sending raw: ", &EMS_RxTelegram, COLOR_CYAN, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EMS_TxTelegram.data[EMS_TxTelegram.length - 1] = _crcCalculator(EMS_TxTelegram.data, EMS_TxTelegram.length); // add the CRC
|
||||||
emsuart_tx_buffer(EMS_TxTelegram.data, EMS_TxTelegram.length); // send the telegram to the UART Tx
|
emsuart_tx_buffer(EMS_TxTelegram.data, EMS_TxTelegram.length); // send the telegram to the UART Tx
|
||||||
EMS_TxQueue.shift(); // remove from queue
|
EMS_TxQueue.shift(); // and remove from queue
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2023,7 +2031,9 @@ void ems_doReadCommand(uint16_t type, uint8_t dest, bool forceRefresh) {
|
|||||||
|
|
||||||
// if we're preventing all outbound traffic, quit
|
// if we're preventing all outbound traffic, quit
|
||||||
if (EMS_Sys_Status.emsTxDisabled) {
|
if (EMS_Sys_Status.emsTxDisabled) {
|
||||||
myDebug_P(PSTR("in Listen Mode. All Tx is disabled."));
|
if (ems_getLogging() != EMS_SYS_LOGGING_NONE) {
|
||||||
|
myDebug_P(PSTR("in Listen Mode. All Tx is disabled."));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -182,11 +182,13 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
|
|||||||
// automatically be sent when the tx fifo is empty
|
// automatically be sent when the tx fifo is empty
|
||||||
tmp = (1 << UCBRK);
|
tmp = (1 << UCBRK);
|
||||||
USC0(EMSUART_UART) |= (tmp); // set bit
|
USC0(EMSUART_UART) |= (tmp); // set bit
|
||||||
if (EMS_Sys_Status.emsTxMode <= 2) {
|
|
||||||
delayMicroseconds(EMSUART_TX_BRK_WAIT); // classic mode
|
if (EMS_Sys_Status.emsTxMode <= 2) { // classic mode
|
||||||
} else if (EMS_Sys_Status.emsTxMode == 3) {
|
delayMicroseconds(EMSUART_TX_BRK_WAIT);
|
||||||
|
} else if (EMS_Sys_Status.emsTxMode == 3) { // junkers mode
|
||||||
delayMicroseconds(EMSUART_TX_WAIT_BRK - EMSUART_TX_LAG); // 1144 (11 Bits)
|
delayMicroseconds(EMSUART_TX_WAIT_BRK - EMSUART_TX_LAG); // 1144 (11 Bits)
|
||||||
}
|
}
|
||||||
|
|
||||||
USC0(EMSUART_UART) &= ~(tmp); // clear bit
|
USC0(EMSUART_UART) &= ~(tmp); // clear bit
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -204,7 +206,7 @@ static inline void ICACHE_FLASH_ATTR emsuart_loopback(bool enable) {
|
|||||||
* Send to Tx, ending with a <BRK>
|
* Send to Tx, ending with a <BRK>
|
||||||
*/
|
*/
|
||||||
void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
void ICACHE_FLASH_ATTR emsuart_tx_buffer(uint8_t * buf, uint8_t len) {
|
||||||
if (EMS_Sys_Status.emsTxMode == 0) { // Classic logic
|
if (EMS_Sys_Status.emsTxMode == 0) { // classic mode logic
|
||||||
for (uint8_t i = 0; i < len; i++) {
|
for (uint8_t i = 0; i < len; i++) {
|
||||||
USF(EMSUART_UART) = buf[i];
|
USF(EMSUART_UART) = buf[i];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user