Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mart Lubbers
CleanSerial
Commits
3268b10b
Commit
3268b10b
authored
Mar 06, 2018
by
Mart Lubbers
Browse files
Add windows stub
parent
c709ac65
Changes
5
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
3268b10b
Clean System Files/[^.]*
TTY
sapl
TTY.prj
test
*.exe
*.prj
*.prp
*-sapl
*-www
Makefile
View file @
3268b10b
CLEAN_HOME
?=
/opt/clean
GCCVERSIONGTEQ6
:=
$(
shell
expr
`
gcc
-dumpversion
|
cut
-f1
-d
.
`
\>
=
6
)
test
:
test.icl TTY.icl TTY.dcl Clean
\
System
\
Files/ctty.o
ifeq
"$(GCCVERSIONGTEQ6)" "1"
clm
-dynamics
-l
-no-pie
-I
$(CLEAN_HOME)
/lib/Dynamics
$(
basename
$<
)
-o
$@
else
clm
-dynamics
-I
$(CLEAN_HOME)
/lib/Dynamics
$(
basename
$<
)
-o
$@
endif
Clean\ System\ Files/ctty.o
:
tty.c
mkdir
-p
Clean
\
System
\
Files
ifeq
"$(GCCVERSIONGTEQ6)" "1"
gcc
-c
$<
-o
"
$@
"
ifeq
($(OS), Windows_NT)
Clean\ System\ Files/ctty.o
:
tty_win.c
else
gcc
-c
$<
-o
"
$@
"
Clean\ System\ Files/ctty.o
:
tty_posix.c
endif
mkdir
-p
Clean
\
System
\
Files
gcc
-c
$<
-o
"
$@
"
clean
:
$(RM)
-r
Clean
\
System
\
Files/
*
test
TTY.icl
View file @
3268b10b
...
...
@@ -6,6 +6,7 @@ import StdString
import
StdChar
import
code
from
"ctty."
import
code
from
library
"msvcrt.txt"
::
*
TTY
:==
Int
...
...
tty.c
→
tty
_posix
.c
View file @
3268b10b
...
...
@@ -5,10 +5,11 @@
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<sys/ioctl.h>
#include
<termios.h>
#include
<time.h>
#include
<termios.h>
#include
<sys/ioctl.h>
#include
"Clean.h"
#ifdef DEBUG
...
...
tty_win.c
0 → 100644
View file @
3268b10b
//#include <ctype.h>
//#include <errno.h>
//#include <fcntl.h>
//#include <unistd.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
//#include <time.h>
//
//#include <termios.h>
//#include <sys/ioctl.h>
#include
"Clean.h"
#ifdef DEBUG
#define debug(s) {puts(s); fflush(stdout);}
#else
#define debug(s) ;
#endif
//#ifdef __APPLE__
//int CMSPAR = 0;
//#endif
//
//#define INITIAL_BUFFERSIZE 2
#define die(s) {perror(s);exit(EXIT_FAILURE);}
//static speed_t baudrates[] = {B0, B50, B75, B110, B134, B150, B200, B300, B600,
// B1200, B1800, B2400, B4800, B9600, B19200, B38400, B57600, B115200,
// B230400};
//static int bytesizes[4] = {CS5, CS6, CS7, CS8};
static
char
*
error
=
""
;
//
//struct termioslist
//{
// int fd;
// struct termios to;
// struct termioslist *next;
//};
//
//struct termioslist *head = NULL;
//static void *my_malloc(size_t s)
//{
// void *r = malloc(s);
// if(r == NULL)
// die("malloc");
// return r;
//}
//static struct termios *getTermios(int fd)
//{
// struct termioslist *h = head;
// while(h != NULL)
// if(h->fd == fd)
// return &h->to;
// return NULL;
//}
//
//static void remTermios(int fd)
//{
// struct termioslist *beforeit = NULL;
// struct termioslist *it = head;
// while(it != NULL){
// if(it->fd == fd){
// if(beforeit == NULL)
// head = it->next;
// else
// beforeit->next = it->next;
// free(it);
// break;
// }
// beforeit = it;
// it = it->next;
// }
//}
//
//static char *cleanStringToCString(CleanString s)
//{
// unsigned long len = CleanStringLength(s);
// char *cs = (char *)my_malloc(len+1);
// memcpy(cs, CleanStringCharacters(s), len);
// cs[len] = '\0';
// return cs;
//}
//
//static void addTermios(int fd, struct termios *t)
//{
// struct termioslist *new = my_malloc(sizeof(struct termioslist));
// new->fd = fd;
// memcpy(&new->to, t, sizeof(struct termios));
// new->next = NULL;
// if(head == NULL){
// head = new;
// } else {
// struct termioslist *h = head;
// while(h->next != NULL)
// h = h->next;
// h->next = new;
// }
//}
//
void
ttyopen
(
CleanString
fn
,
int
baudrate
,
int
bytesize
,
int
parity
,
int
stopbits
,
int
xonoff
,
int
*
status
,
int
*
fd
)
{
}
// debug("ttyopen");
// struct termios tio;
// char *cs_fn = cleanStringToCString(fn);
// debug(cs_fn);
// *fd = open(cs_fn, O_RDWR | O_NOCTTY | O_NONBLOCK);
// *status = 0;
// fcntl(*fd, F_SETFL, 0);
// if(*fd < 0){
// error = strerror(errno);
// } else {
// //Get
// tcgetattr(*fd, &tio);
// addTermios(*fd, &tio);
// //Baudrate
// cfsetispeed(&tio, baudrates[baudrate]);
// //Bytesize
// tio.c_cflag &= ~CSIZE;
// tio.c_cflag |= bytesizes[bytesize];
// //Parity
// if(parity == 0) {
// tio.c_cflag &= ~PARENB | ~INPCK;
// } else if(parity == 1) {
// tio.c_cflag |= PARODD | PARENB;
// } else if(parity == 2) {
// tio.c_cflag |= PARENB;
// tio.c_cflag &= ~PARODD;
// } else if(parity == 3) {
// tio.c_cflag |= PARENB | CMSPAR;
// tio.c_cflag &= ~PARODD;
// } else if( parity == 4) {
// tio.c_cflag |= PARENB | CMSPAR | PARODD;
// }
// //Stopbits
// if(stopbits != 0)
// tio.c_cflag |= CSTOPB;
// else
// tio.c_cflag &= ~CSTOPB;
// //Xonoff
// if(xonoff == 1)
// tio.c_cflag |= IXON;
// else
// tio.c_cflag &= ~IXON;
// //Set
// tio.c_oflag = 0;
// tio.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
//// tio.c_lflag |= ICANON;
//
// tio.c_cc[VMIN]=5;
// tio.c_cc[VTIME]=0;
// tcsetattr(*fd, TCSANOW, &tio);
//
// *status = 1;
// error = strerror(errno);
// }
// free(cs_fn);
// debug("ttyopen-done");
//}
//
unsigned
long
*
errcl
=
NULL
;
void
ttyerror
(
CleanString
*
result
)
{
debug
(
"ttyerror"
);
// if(errcl != NULL)
// free(errcl);
// errcl = my_malloc(
// sizeof(unsigned long)*CleanStringSizeInts(strlen(error)));
// *result = (CleanString) errcl;
// memcpy(CleanStringCharacters(errcl), error, strlen(error));
// CleanStringLength(errcl) = strlen(error);
// debug("ttyerror-done");
}
void
ttyread
(
int
fd
,
int
*
ch
,
int
*
fdo
)
{
// debug("ttyread");
// unsigned int c;
// if(read(fd, &c, 1) == -1){
// die("read");
// }
// *ch = (int)c;
// *fdo = fd;
// debug("ttyread done");
}
void
ttyavailable
(
int
fd
,
int
*
r
,
int
*
fdo
)
{
// debug("ttyavailable");
// fd_set fds;
// struct timeval tv;
// tv.tv_sec = 0;
// tv.tv_usec = 0;
//
// FD_ZERO(&fds);
// FD_SET(fd, &fds);
//
// *r = select(fd+1, &fds, NULL, NULL, &tv);
// if(*r == -1)
// die("select");
// *fdo = fd;
// debug("ttyavailable-done");
}
int
ttywrite
(
CleanString
s
,
int
fd
)
{
debug
(
"ttywrite"
);
// int i;
// for(i = 0; i< CleanStringLength(s); i++){
// unsigned char c = ((unsigned char*)CleanStringCharacters(s))[i];
// printf("%02x(%u) ", c, c);
// }
// write(fd, (void *)CleanStringCharacters(s), CleanStringLength(s));
// tcdrain(fd);
// debug("ttywrite-done");
// return fd;
}
int
ttyclose
(
int
fd
)
{
debug
(
"ttyclose"
);
// struct termios *to = getTermios(fd);
// tcsetattr(fd, TCSANOW, to);
// remTermios(fd);
// int ret = close(fd);
// error = strerror(errno);
// debug("ttyclose-done");
// return ret + 1;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment