Voici le code
#define MYSERIAL Serial1
#define MAX_CMD_SIZE 96
#define BUFSIZE 4
#define LCD_MESSAGEGCODE(x) lcd_setstatusgcode(PSTR(x))
static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
static char *strchr_pointer;
static char serial_char;
static char cmdbuffer[BUFSIZE][MAX_CMD_SIZE];
static int bufindr = 0;
static int bufindw = 0;
static int buflen = 0;
static int serial_count = 0;
static boolean comment_mode = false;
void setup() {
// put your setup code here, to run once:
MYSERIAL.begin(19200);
}
void loop() {
// put your main code here, to run repeatedly:
get_command();
}
void get_command(){
while( MYSERIAL.available() > 0 && buflen < BUFSIZE) {
serial_char = MYSERIAL.read();
if(serial_char == '\n' ||
serial_char == '\r' ||
serial_char == ':')
{
if(!serial_count) { //if empty line
comment_mode = false; //for new command
return;
}
cmdbuffer[bufindw][serial_count] = 0; //terminate string
if(!comment_mode){
comment_mode = false; //for new command
if(strchr(cmdbuffer[bufindw], 'N') != NULL)
{
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
LCD_MESSAGEGCODE(gcode_N)
}
}
}
}
}
void lcd_setstatusgcode(long int*message)
{
}
Merci