Skip to content

Commit 47b9598

Browse files
author
Bs0Dd
committed
Direct access to termios instead of stty utility
1 parent 0d74e16 commit 47b9598

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

coverett.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
bus_t openBus(char* path){
55
bus_t newbus = fopen(path, "r+");
66
if (newbus != NULL){
7-
char* cmd = (char*) malloc (19+strlen(path));
8-
sprintf(cmd, "stty -F %s raw -echo", path);
9-
system(cmd);
10-
free(cmd);
7+
int fd = fileno(newbus);
8+
struct termios tcattr;
9+
tcgetattr(fd, &tcattr);
10+
cfmakeraw(&tcattr);
11+
tcsetattr(fd, TCSANOW, &tcattr);
1112
}
1213
return newbus;
1314
}
@@ -106,7 +107,7 @@ device_t findDev(bus_t bus, char* name){
106107
return proxyDevByList(bus, list, id);
107108
}
108109

109-
list_t getMethods(device_t* device){ //TODO: Methods parsing
110+
list_t getMethods(device_t* device){ //TODO: Methods parsing!!!
110111
if (!existsStatus(device)) return (list_t){CO_ERROR, NULL};
111112
char reqbody[65];
112113
sprintf(reqbody, "{\"type\":\"methods\",\"data\":\"%s\"}", device->devId);

coverett.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ extern "C"{
88
#include <stdio.h>
99
#include <stdlib.h>
1010
#include <string.h>
11+
#include <termios.h>
1112
#include "cJSON/cJSON.h"
1213

1314
typedef enum TYPES {

0 commit comments

Comments
 (0)