cosemtic changes

This commit is contained in:
Paul
2019-06-08 17:18:38 +02:00
parent 3c6215c3eb
commit 4b7db73e74
2 changed files with 25 additions and 13 deletions

View File

@@ -550,6 +550,15 @@ void _ems_sendTelegram() {
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
// we don't remove from the queue yet
_EMS_TxTelegram EMS_TxTelegram = EMS_TxQueue.first();
@@ -561,19 +570,18 @@ void _ems_sendTelegram() {
}
// 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) {
_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) {
_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);
}
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
EMS_TxQueue.shift(); // remove from queue
EMS_TxQueue.shift(); // and remove from queue
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 (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;
}

View File

@@ -182,11 +182,13 @@ void ICACHE_FLASH_ATTR emsuart_tx_brk() {
// automatically be sent when the tx fifo is empty
tmp = (1 << UCBRK);
USC0(EMSUART_UART) |= (tmp); // set bit
if (EMS_Sys_Status.emsTxMode <= 2) {
delayMicroseconds(EMSUART_TX_BRK_WAIT); // classic mode
} else if (EMS_Sys_Status.emsTxMode == 3) {
if (EMS_Sys_Status.emsTxMode <= 2) { // classic mode
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)
}
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>
*/
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++) {
USF(EMSUART_UART) = buf[i];
}