Add missing SerialHelper files

This commit is contained in:
John Lewin 2018-05-09 15:22:31 -07:00
parent 682ff24209
commit 5dfb7c6d4a
2 changed files with 71 additions and 0 deletions

View file

@ -0,0 +1,60 @@
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#include <linux/termios.h>
int ioctl(int d, int request, ...);
int set_baud (char *devfile, int baud);
int set_baud(char *devfile, int baud)
{
#ifndef __linux__
return 0;
#endif
struct termios2 t;
int fd;
fd = open(devfile, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
{
fprintf(stderr, "error opening %s: %s", devfile, strerror(errno));
return 2;
}
if (ioctl(fd, TCGETS2, &t))
{
perror("TCGETS2");
return 3;
}
printf("SetSerial: Reported speed before update %d\n", t.c_ospeed);
t.c_cflag &= ~CBAUD;
t.c_cflag |= BOTHER;
t.c_ispeed = baud;
t.c_ospeed = baud;
if (ioctl(fd, TCSETS2, &t))
{
perror("TCSETS2");
return 4;
}
if (ioctl(fd, TCGETS2, &t))
{
perror("TCGETS2");
return 5;
}
//close(fd);
printf("SetSerial: Reported speed after update %d\n", t.c_ospeed);
return 0;
}

View file

@ -0,0 +1,11 @@
# Build libSetSerial.so
gcc -m32 -shared -fPIC SetSerial.c -o libSetSerial.so -v
gcc -shared -fPIC SetSerial.c -o libSetSerial -v
# Create path if needed
mkdir -p ../../../../bin/Debug/
mkdir -p ../../../../bin/Release/
# Copy to MatterControl build directories
cp libSetSerial* ../../../../bin/Debug/
cp libSetSerial* ../../../../bin/Release/