Initial commit
Some checks failed
Build Kernel / Build all affected Kernels (push) Has been cancelled
Build all core packages / Build all core packages for selected target (push) Has been cancelled
Build and Push prebuilt tools container / Build and Push all prebuilt containers (push) Has been cancelled
Build Toolchains / Build Toolchains for each target (push) Has been cancelled
Build host tools / Build host tools for linux and macos based systems (push) Has been cancelled
Coverity scan build / Coverity x86/64 build (push) Has been cancelled

This commit is contained in:
domenico
2025-06-24 12:51:15 +02:00
commit 27c9d80f51
10493 changed files with 1885777 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,7 @@ SCRIPTPATH = /etc/comgt/
SCRIPTSRC = ./scripts/
BIN = $(CPROG)
MANP = comgt.1 sigmon.1
+CC = cc
CFLAGS = -c
LDFLAGS =
@@ -70,10 +71,5 @@ clean:
-rm *~
-rm $(SCRIPTSRC)*~
-
-comgt: comgt.o
- cc comgt.o $(LDFLAGS) -o comgt
-
-comgt.o: comgt.c comgt.h
- cc comgt.c $(CFLAGS)
-
+comgt: comgt.c comgt.h
+ $(CC) $(CFLAGS) -o comgt $< $(LDFLAGS)

View File

@@ -0,0 +1,105 @@
--- a/comgt.c
+++ b/comgt.c
@@ -30,7 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
-#include <termio.h>
+#include <termios.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
@@ -81,7 +81,7 @@ char token[MAXTOKEN]; /* For gettoken(
char scriptfile[MAXPATH]; /* Script file name */
char scriptfilepath[MAXPATH]; /* temp storage for full path */
BOOL verbose=0; /* Log actions */
-struct termio cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */
+struct termios cons, stbuf, svbuf; /* termios: svbuf=before, stbuf=while */
int comfd=0; /* Communication file descriptor. Defaults to stdin. */
char msg[STRINGL]; /* Massage messages here */
int preturn,returns[MAXGOSUBS];
@@ -172,7 +172,7 @@ void dotestkey(void) {
/* Exit after resetting terminal settings */
void ext(long xtc) {
- ioctl(1, TCSETA, &cons);
+ ioctl(1, TCSETS, &cons);
exit(xtc);
}
@@ -920,24 +920,24 @@ BOOL getonoroff(void) {
void setcom(void) {
stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
- if (ioctl(comfd, TCSETA, &stbuf) < 0) {
+ if (ioctl(comfd, TCSETS, &stbuf) < 0) {
serror("Can't ioctl set device",1);
}
}
void doset(void) {
- struct termio console;
+ struct termios console;
int a,b;
gettoken();
if(strcmp(token,"echo")==0) {
a=0;
if(getonoroff()) a=ECHO|ECHOE;
- if(ioctl(0, TCGETA, &console)<0) {
+ if(ioctl(0, TCGETS, &console)<0) {
serror("Can't ioctl FD zero!\n",2);
}
console.c_lflag &= ~(ECHO | ECHOE);
console.c_lflag |= a;
- ioctl(0, TCSETA, &console);
+ ioctl(0, TCSETS, &console);
}
else if(strcmp(token,"senddelay")==0) {
senddelay=10000L*getdvalue();
@@ -1224,7 +1224,7 @@ void doclose(void) {
if(strcmp(token,"hardcom")==0) {
if(comfd== -1) serror("Com device not open",1);
vmsg("Closing device");
- if (ioctl(comfd, TCSETA, &svbuf) < 0) {
+ if (ioctl(comfd, TCSETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl set device %s.\n",device);
serror(msg,1);
}
@@ -1266,12 +1266,12 @@ void opengt(void) {
ext(1);
}
}
- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
+ if (ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't control %s, please try again.\n",device);
serror(msg,1);
}
setenv("COMGTDEVICE",device,1);
- ioctl(comfd, TCGETA, &stbuf);
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
if (high_speed == 0) strcpy(cspeed,"115200");
else strcpy(cspeed,"57600");
@@ -1303,11 +1303,11 @@ void opendevice(void) {
}
else comfd=0;
- if (ioctl (comfd, TCGETA, &svbuf) < 0) {
+ if (ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl get device %s.\n",device);
serror(msg,1);
}
- ioctl(comfd, TCGETA, &stbuf);
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
switch(speed) {
case B0: strcpy(cspeed,"0");break;
@@ -1553,7 +1553,7 @@ int main(int argc,char **argv) {
skip_default=0;
filep=NULL;
scriptspace=4096;
- ioctl(1, TCGETA, &cons);
+ ioctl(1, TCGETS, &cons);
if((script=( char *)malloc(scriptspace))==NULL) {
serror("Could not malloc()",3);
}

View File

@@ -0,0 +1,20 @@
--- a/comgt.c
+++ b/comgt.c
@@ -1281,7 +1281,7 @@ void opengt(void) {
parity=stbuf.c_cflag & (PARENB | PARODD);
stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXANY | IGNPAR );
stbuf.c_oflag &= ~(OPOST | OLCUC | OCRNL | ONLCR | ONLRET);
- stbuf.c_lflag &= ~(ICANON | XCASE | ECHO | ECHOE | ECHONL);
+ stbuf.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL);
stbuf.c_lflag &= ~(ECHO | ECHOE);
stbuf.c_cc[VMIN] = 1;
stbuf.c_cc[VTIME] = 0;
@@ -1336,7 +1336,7 @@ void opendevice(void) {
parity=stbuf.c_cflag & (PARENB | PARODD);
stbuf.c_iflag &= ~(IGNCR | ICRNL | IUCLC | INPCK | IXON | IXANY | IGNPAR );
stbuf.c_oflag &= ~(OPOST | OLCUC | OCRNL | ONLCR | ONLRET);
- stbuf.c_lflag &= ~(ICANON | XCASE | ECHO | ECHOE | ECHONL);
+ stbuf.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHONL);
stbuf.c_lflag &= ~(ECHO | ECHOE);
stbuf.c_cc[VMIN] = 1;
stbuf.c_cc[VTIME] = 0;

View File

@@ -0,0 +1,68 @@
--- a/comgt.c
+++ b/comgt.c
@@ -91,6 +91,7 @@ unsigned long hstart,hset;
char NullString[]={ "" };
BOOL lastcharnl=1; /* Indicate that last char printed from getonebyte
was a nl, so no new one is needed */
+BOOL tty=1;
//"open com \"/dev/modem\"\nset com 38400n81\nset senddelay 0.05\nsend \"ATi^m\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response :\",$s,\"\\n\"\nget 2 \" ^m\" $s\nprint \"Response : \",$s,\"\\n\"\n\n";
@@ -920,7 +921,7 @@ BOOL getonoroff(void) {
void setcom(void) {
stbuf.c_cflag &= ~(CBAUD | CSIZE | CSTOPB | CLOCAL | PARENB);
stbuf.c_cflag |= (speed | bits | CREAD | clocal | parity | stopbits );
- if (ioctl(comfd, TCSETS, &stbuf) < 0) {
+ if (tty && ioctl(comfd, TCSETS, &stbuf) < 0) {
serror("Can't ioctl set device",1);
}
}
@@ -1224,7 +1225,7 @@ void doclose(void) {
if(strcmp(token,"hardcom")==0) {
if(comfd== -1) serror("Com device not open",1);
vmsg("Closing device");
- if (ioctl(comfd, TCSETS, &svbuf) < 0) {
+ if (tty && ioctl(comfd, TCSETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl set device %s.\n",device);
serror(msg,1);
}
@@ -1266,12 +1267,17 @@ void opengt(void) {
ext(1);
}
}
- if (ioctl (comfd, TCGETS, &svbuf) < 0) {
+ if (isatty (comfd))
+ tty=1;
+ else
+ tty=0;
+ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't control %s, please try again.\n",device);
serror(msg,1);
}
setenv("COMGTDEVICE",device,1);
- ioctl(comfd, TCGETS, &stbuf);
+ if (tty)
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
if (high_speed == 0) strcpy(cspeed,"115200");
else strcpy(cspeed,"57600");
@@ -1302,12 +1308,16 @@ void opendevice(void) {
}
}
else comfd=0;
-
- if (ioctl (comfd, TCGETS, &svbuf) < 0) {
+ if (isatty (comfd))
+ tty=1;
+ else
+ tty=0;
+ if (tty && ioctl (comfd, TCGETS, &svbuf) < 0) {
sprintf(msg,"Can't ioctl get device %s.\n",device);
serror(msg,1);
}
- ioctl(comfd, TCGETS, &stbuf);
+ if (tty)
+ ioctl(comfd, TCGETS, &stbuf);
speed=stbuf.c_cflag & CBAUD;
switch(speed) {
case B0: strcpy(cspeed,"0");break;