From 0ac193e41e03faba8dc451177fa2b5e8936bd203 Mon Sep 17 00:00:00 2001 From: Michel Stempin Date: Mon, 11 May 2020 22:15:58 +0200 Subject: [PATCH] Added termfix --- Makefile | 6 ++++-- termfix.c | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 termfix.c diff --git a/Makefile b/Makefile index 658b749..d162fa7 100755 --- a/Makefile +++ b/Makefile @@ -2,11 +2,13 @@ TOOLS_CFLAGS := -Wall -std=c99 -D _DEFAULT_SOURCE # # Programs # -all: funkey_gpio_management +all: funkey_gpio_management termfix -funkey_gpio_management: funkey_gpio_management.o gpio-utils.o uinput.o gpio_mapping.o read_conf_file.o keydefs.o driver_pcal6416a.o driver_axp209.o smbus.o +funkey_gpio_management: funkey_gpio_management.o gpio-utils.o uinput.o gpio_mapping.o read_conf_file.o keydefs.o driver_pcal6416a.o driver_axp209.o smbus.o $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ +termfix: termfix.o + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ # # Objects diff --git a/termfix.c b/termfix.c new file mode 100644 index 0000000..9eb832d --- /dev/null +++ b/termfix.c @@ -0,0 +1,36 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char** argv) { + if (argc != 2) { + printf("usage: termfix /dev/ttyX\n"); + return 2; + } + + int fd = open(argv[1], O_RDWR, 0); + int res = ioctl(fd, VT_UNLOCKSWITCH, 1); + + if (res != 0) { + perror("ioctl VT_UNLOCKSWITCH failed"); + return 3; + } + + ioctl(fd, KDSETMODE, KD_TEXT); + + if (res != 0) { + perror("ioctl KDSETMODE failed"); + return 3; + } + + printf("Success\n"); + + return res; +}