replace printf as puts
This commit is contained in:
parent
55528a6363
commit
c2e628b33e
@ -32,7 +32,7 @@ int main(int argc, char **argv) {
|
||||
check(sp_set_parity(serial_port, SP_PARITY_NONE));
|
||||
check(sp_set_stopbits(serial_port, 1));
|
||||
check(sp_set_flowcontrol(serial_port, SP_FLOWCONTROL_NONE));
|
||||
puts("Connected.\n");
|
||||
puts("Connected.");
|
||||
|
||||
|
||||
while (true) {
|
||||
@ -42,10 +42,10 @@ int main(int argc, char **argv) {
|
||||
result = check(sp_blocking_read(serial_port, buffer + pos, 1, timeout));
|
||||
|
||||
if (result == -1) {
|
||||
printf("Error reading from serial port\n");
|
||||
puts("Error reading from serial port");
|
||||
break;
|
||||
} else if (result == 0) {
|
||||
printf("No more data\n");
|
||||
puts("No more data");
|
||||
break;
|
||||
} else {
|
||||
if (buffer[pos] == '\n') {
|
||||
@ -66,12 +66,11 @@ int main(int argc, char **argv) {
|
||||
|
||||
/* Helper function for error handling. */
|
||||
int check(enum sp_return result) {
|
||||
/* For this example we'll just exit on any error by calling abort(). */
|
||||
char *error_message;
|
||||
|
||||
switch (result) {
|
||||
case SP_ERR_ARG:
|
||||
printf("Error: Invalid argument.\n");
|
||||
puts("Error: Invalid argument.");
|
||||
abort();
|
||||
case SP_ERR_FAIL:
|
||||
error_message = sp_last_error_message();
|
||||
@ -79,10 +78,10 @@ int check(enum sp_return result) {
|
||||
sp_free_error_message(error_message);
|
||||
abort();
|
||||
case SP_ERR_SUPP:
|
||||
printf("Error: Not supported.\n");
|
||||
puts("Error: Not supported.");
|
||||
abort();
|
||||
case SP_ERR_MEM:
|
||||
printf("Error: Couldn't allocate memory.\n");
|
||||
puts("Error: Couldn't allocate memory.");
|
||||
abort();
|
||||
case SP_OK:
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user