Remove old serial.c code
This commit is contained in:
1 parent
2002ba27a2
commit
603a64757d
4 files changed
+5
-91
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
include ../config.mk
|
||||
OBJ=main.o hexdump.o dump.o nolo.o serial.o qmode.o
|
||||
OBJ=main.o hexdump.o dump.o nolo.o qmode.o
|
||||
OBJ+=utils.o console.o
|
||||
OBJ+=squeue/squeue.o
|
||||
OBJ+=image.o fiasco.o device.o usb-device.o cold-flash.o
|
||||
|
||||
+3
-3
@@ -200,7 +200,7 @@ void show_usage()
|
||||
printf(" -Q enter shared queues server mode (for gui or remote)\n");
|
||||
#endif
|
||||
printf ("Local stuff:\n"
|
||||
" -s [serial] serial port console (minicom like terminal)\n"
|
||||
// " -s [serial] serial port console (minicom like terminal)\n"
|
||||
" -h show this help message\n"
|
||||
" -S [subversion] unpacks/flash pieces matching this sub-version information\n"
|
||||
" -n do not flash or write to disk (simulation)\n"
|
||||
@@ -480,8 +480,8 @@ int main(int argc, char **argv)
|
||||
case 'e':
|
||||
reverseto = optarg;
|
||||
break;
|
||||
case 's':
|
||||
return console(optarg);
|
||||
// case 's':
|
||||
// return console(optarg);
|
||||
// case 'u':
|
||||
// fiasco_image = optarg;
|
||||
// unpack = 1;
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ extern struct usb_dev_handle *dev;
|
||||
int is_valid_device(struct usb_device_descriptor *udd);
|
||||
//void list_valid_devices();
|
||||
//int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device);
|
||||
int console(const char *device);
|
||||
//int console(const char *device);
|
||||
int connect_via_usb();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||
* Copyright (C) 2007 pancake <pancake@youterm.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "main.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
|
||||
int open_serial(const char *file)
|
||||
{
|
||||
struct termios tc;
|
||||
int fd = open (file, O_RDWR | O_SYNC);
|
||||
if (fd < 0) {
|
||||
perror (file);
|
||||
return -1;
|
||||
}
|
||||
// 115200 baud, 8n1, no flow control
|
||||
tcgetattr(fd, &tc);
|
||||
tc.c_iflag = IGNPAR;
|
||||
tc.c_oflag = 0;
|
||||
tc.c_cflag = CS8 | CREAD | CLOCAL;
|
||||
tc.c_lflag = 0;
|
||||
cfsetispeed(&tc, B115200);
|
||||
cfsetospeed(&tc, B115200);
|
||||
tcsetattr(fd, TCSANOW, &tc);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int console(const char *device)
|
||||
{
|
||||
char str[513];
|
||||
int fd = open_serial(device);
|
||||
int pid;
|
||||
|
||||
if (fd == -1) {
|
||||
fprintf(stderr, "Cannot open serial device %s\n", device);
|
||||
return 1;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid) {
|
||||
while(1) {
|
||||
fgets(str, 512, stdin);
|
||||
if (write(fd, str, strlen(str)-1) == -1) {
|
||||
perror("write");
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
char buf;
|
||||
while(1) {
|
||||
if (read(fd, &buf,1) == -1) {
|
||||
perror("read");
|
||||
exit (1);
|
||||
}
|
||||
write(1, &buf, 1);
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user