Jump to content

Recommended Posts

Posted (edited)

Hi, does anyone know if DCS-BIOS uses interrupts for RS485 slave devices? I'm skimming through the code but it doesn't seem very clear.

Background: I'm trying to run a display for the A-10C CDU with Bodmers HX_8357 library. As good as it is, even with additional optimisations it's too slow to draw the CDU fast enough and it seems like the slave Arduino Mega is losing incoming data due to the drawing. Sometimes part of the display don't update at all, sometimes text entered into the CDU doesn't show up, or shows up partially, and after a while the whole screen gets garbled. I'm assuming the last issue is because the Arduino starts reading data at a random point in the data stream and tries to draw an invalid character and this messes up the drawing with the HX_8357 library. If I connect it directly over USB instead of RS485, it works perfectly fine. I'm assuming this is because USB uses interrupts properly, but the code isn't very clear about RS485. Can someone help me understand this please?

Update: I removed the call to noInterrupts() and im still getting what looks like missing data on the display, while USB keeps working perfectly on same Arduino, display and PC. Only connection method changes.

In DcsBiosNgRS485Slave.cpp.inc:224, they do indeed attach interrupts to the UDRE, RX and TX:

ISR(USART0_RX_vect) { rs485slave.rxISR(); }
ISR(USART0_TX_vect) { rs485slave.txcISR(); }
ISR(USART0_UDRE_vect) { rs485slave.udreISR(); }

However, in Protocol.cpp::21, we find this code, which seems to disable interrupts for RS485 slave devices:

void ProtocolParser::processCharISR(unsigned char c) {
	incomingDataBuffer.put(c);
	if (processingData) return;
	
	processingData = true;
	while (1) {
		if (incomingDataBuffer.isEmpty()) {
			processingData = false;
			return;
		}
		unsigned char nextByte = incomingDataBuffer.get();
		interrupts();
		processChar(nextByte);
#ifdef DCSBIOS_RS485_SLAVE <------------------------------- Why?!
		noInterrupts();
#endif
	}
}

Do I understand this correctly that slaves do not use interrupts, and the slow drawing is indeed what is causing the display issues? If so, does anyone know why the interrupts were disabled for the slaves? Seems like a serious issue to me.

Edited by maciekish
Updated information
Posted

Have you tried using Timer?

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

Posted (edited)
14 hours ago, molevitch said:

Have you tried using Timer?

No, what do you mean? Im only redrawing the display when new data comes in, not in loop().

Edited by maciekish
Posted

Oh, ok. 

Timer is a function which I guess would only affect Loop. 

SCAN Intel Core i9 10850K "Comet Lake", 32GB DDR4, 10GB NVIDIA RTX 3080, HP Reverb G2

Custom Mi-24 pit with magnetic braked cyclic and collective. See it here: Molevitch Mi-24 Pit.

 

[sIGPIC][/sIGPIC] www.blacksharkden.com

bsd sig 2021.jpg

  • maciekish changed the title to Updated: DCS-BIOS RS485 Interrupts
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...