Skip to content

Commit

Permalink
#531 EmbedControl Java API version tracks the project. Make serial bl…
Browse files Browse the repository at this point in the history
…ocking wait configurable
  • Loading branch information
davetcc committed Oct 19, 2024
1 parent ea1ddf0 commit 85c2527
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Rs232RemoteConnector extends StreamRemoteConnector {

public Rs232RemoteConnector(LocalIdentifier localId, String portName, int baud, MenuCommandProtocol protocol,
ScheduledExecutorService executor, Clock clock, ConnectMode connectMode) throws IOException {
super(localId, protocol, executor, clock);
super(localId, protocol, executor, clock, null);
serialPort = Arrays.stream(SerialPort.getCommPorts())
.filter(sp -> sp.getSystemPortName().equals(portName))
.findFirst().orElseThrow(IOException::new);
Expand Down
10 changes: 8 additions & 2 deletions xmlPlugins/core-remote/serialSrc/SerialTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
* make sure to rename it first.
*/

// we'll wait 100 times this amount in a task manager yielding loop when serial
// would block
#ifndef MICROS_TO_WAIT_FOR_SERIAL
#define MICROS_TO_WAIT_FOR_SERIAL 10000
#endif //MICROS_TO_WAIT_FOR_SERIAL

#include "SerialTransport.h"
#include <tcMenu.h>

Expand All @@ -29,11 +35,11 @@ int SerialTagValueTransport::writeChar(char ch) {
serialPort->write(ch);
}
else {
int tries = 30;
int tries = 100;
while(tries && !available()) {
--tries;
serialPort->flush();
taskManager.yieldForMicros(100);
taskManager.yieldForMicros(MICROS_TO_WAIT_FOR_SERIAL);
}

// if it's not available now, it probably will timeout anyway.
Expand Down

0 comments on commit 85c2527

Please sign in to comment.