diff --git a/example/example.c b/example/example.c index 848b14a..19bf01b 100644 --- a/example/example.c +++ b/example/example.c @@ -37,6 +37,9 @@ int main(void) // ---- Test device impl ---- +// Newline sequence for responses. +// Device accepts botn \r\n and \n in incomming messages. +const char *scpi_eol = "\r\n"; const SCPI_error_desc scpi_user_errors[] = { {10, "Custom error"}, diff --git a/include/scpi_parser.h b/include/scpi_parser.h index 93cecee..a8af4a6 100644 --- a/include/scpi_parser.h +++ b/include/scpi_parser.h @@ -70,6 +70,9 @@ extern const SCPI_command_t scpi_commands_builtin[]; /** Send a byte to master (may be buffered) */ extern void scpi_send_byte_impl(uint8_t b); +/** Character sequence used as a newline in responses. */ +extern const char *scpi_eol; + // --------------- functions -------------------- diff --git a/source/scpi_builtins.c b/source/scpi_builtins.c index 4f2c113..831799f 100644 --- a/source/scpi_builtins.c +++ b/source/scpi_builtins.c @@ -165,7 +165,7 @@ static void builtin_SYST_ERR_ALLq(const SCPI_argval_t *args) scpi_send_string_raw(sbuf); } - scpi_send_string_raw("\r\n"); // eol + scpi_send_string_raw(scpi_eol); } @@ -208,7 +208,7 @@ static void builtin_SYST_ERR_CODE_ALLq(const SCPI_argval_t *args) scpi_send_string_raw(sbuf); } - scpi_send_string_raw("\r\n"); // eol + scpi_send_string_raw(scpi_eol); } diff --git a/source/scpi_parser.c b/source/scpi_parser.c index f5b43fe..195aac6 100644 --- a/source/scpi_parser.c +++ b/source/scpi_parser.c @@ -134,9 +134,7 @@ void scpi_send_string_raw(const char *message) void scpi_send_string(const char *message) { scpi_send_string_raw(message); - - scpi_send_byte_impl('\r'); - scpi_send_byte_impl('\n'); + scpi_send_string_raw(scpi_eol); } // ------- Error shortcuts ----------