Skip to content

Commit 3c6f3e2

Browse files
committed
Made keep-alive token a configuration option. Default (newline) tested with both repsnapper and pronterface.
1 parent 5796ea1 commit 3c6f3e2

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

bebopr.h

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern int bebopr_pre_init( void);
1515
// Configuration
1616

1717
extern int config_e_axis_is_always_relative( void);
18+
extern char config_keep_alive_char( void);
1819

1920
// determines stepper driver control
2021
extern int config_use_pololu_drivers( void);

bebopr_r2.c

+13
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,16 @@ int config_e_axis_is_always_relative( void)
324324
{
325325
return 0;
326326
}
327+
328+
/*
329+
* Specify the character code that should be used for keep-alive messages.
330+
* This character should not disturb the communication.
331+
* Pronterface seems to accept most characters, but only a newline
332+
* does not disturb the program.
333+
* Repsnapper also accepts the newline without causing problems.
334+
*/
335+
char config_keep_alive_char( void)
336+
{
337+
return '\n';
338+
}
339+

comm.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ static void* comm_thread( void* arg)
6363
char pending_input;
6464
char pending_output;
6565
int prescaler = 0;
66+
char keep_alive_char = config_keep_alive_char();
6667
/*
6768
* The data from the stdout pipe does not become available until
6869
* stdout is flushed. So the timer is set to a short cycle that
@@ -83,7 +84,7 @@ static void* comm_thread( void* arg)
8384
} else if (rc == 0 || (rc < 0 && errno == EINTR)) {
8485
// timeout, send dummy character to keep connection alive
8586
if (++prescaler > keep_alive_timeout / timeout) {
86-
printf( "%c", 10); // only safe code for pronterface !
87+
printf( "%c", keep_alive_char);
8788
fprintf( stderr, "<KEEP ALIVE SENT>");
8889
prescaler = 0;
8990
}

0 commit comments

Comments
 (0)