configurable newline

master 0.1.1
Ondřej Hruška 9 years ago
parent b4bc96696a
commit 808637a779
  1. 3
      example/example.c
  2. 3
      include/scpi_parser.h
  3. 4
      source/scpi_builtins.c
  4. 4
      source/scpi_parser.c

@ -37,6 +37,9 @@ int main(void)
// ---- Test device impl ---- // ---- 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[] = { const SCPI_error_desc scpi_user_errors[] = {
{10, "Custom error"}, {10, "Custom error"},

@ -70,6 +70,9 @@ extern const SCPI_command_t scpi_commands_builtin[];
/** Send a byte to master (may be buffered) */ /** Send a byte to master (may be buffered) */
extern void scpi_send_byte_impl(uint8_t b); extern void scpi_send_byte_impl(uint8_t b);
/** Character sequence used as a newline in responses. */
extern const char *scpi_eol;
// --------------- functions -------------------- // --------------- functions --------------------

@ -165,7 +165,7 @@ static void builtin_SYST_ERR_ALLq(const SCPI_argval_t *args)
scpi_send_string_raw(sbuf); 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(sbuf);
} }
scpi_send_string_raw("\r\n"); // eol scpi_send_string_raw(scpi_eol);
} }

@ -134,9 +134,7 @@ void scpi_send_string_raw(const char *message)
void scpi_send_string(const char *message) void scpi_send_string(const char *message)
{ {
scpi_send_string_raw(message); scpi_send_string_raw(message);
scpi_send_string_raw(scpi_eol);
scpi_send_byte_impl('\r');
scpi_send_byte_impl('\n');
} }
// ------- Error shortcuts ---------- // ------- Error shortcuts ----------

Loading…
Cancel
Save