diff options
Diffstat (limited to 'src/host')
-rw-r--r-- | src/host/pipe_image.c | 63 |
1 files changed, 11 insertions, 52 deletions
diff --git a/src/host/pipe_image.c b/src/host/pipe_image.c index 105f9a1..3543053 100644 --- a/src/host/pipe_image.c +++ b/src/host/pipe_image.c @@ -3,26 +3,16 @@ #include <endian.h> #include <stdint.h> #include <sys/types.h> -#include "rs232.h" #define ANSI_FG_RED "\033[0;31m" #define ANSI_FG_DEFAULT "\033[0;39m" -/* This program pipes it's argument file to /dev/ttyUSB0 or stdout */ +/* This program pipes it's argument file to stdout */ /* prepending it with it's size (4 bytes, little endian). */ /* It is intended to be used with our bootloader. */ int main(int argc, const char **argv) { const char *image_file_name = "kernel.img"; - _Bool stdout_instead_of_uart = 0; - - if (argc > 1) - if (!strcmp(argv[1], "--stdout")) - { - stdout_instead_of_uart = 1; - argc--; - argv++; - } if (argc > 1) image_file_name = argv[1]; @@ -46,26 +36,10 @@ int main(int argc, const char **argv) { if (fseek(image_file_handle, 0, SEEK_SET)) err(-1, "error navigating through file"); - //init comport - const int comport=16; - - if (!stdout_instead_of_uart) - if (RS232_OpenComport(comport, 115200, "8N1", 1) == 1) - err(-1, "Error opening comport"); - uint32_t image_size_le = htole32(image_size); - if (stdout_instead_of_uart) - { - if (fwrite((unsigned char*) &image_size_le, 4, 1, stdout) != 1) - err(-1, "error writing number to stdout"); - } - else - { - if (RS232_SendBuf(comport, (unsigned char*) &image_size_le, 4) - == -1) - err(-1, "error writing number to serial"); - } + if (fwrite((unsigned char*) &image_size_le, 4, 1, stdout) != 1) + err(-1, "error writing number to stdout"); ssize_t bytes_left = image_size; @@ -77,36 +51,21 @@ int main(int argc, const char **argv) { < 1) err(-1, "error reading the file"); - if (stdout_instead_of_uart) - { - if (fwrite((unsigned char*) buf, bytes_read, 1, stdout) != 1) - err(-1, "error writing to stdout"); - } - else - { - if (RS232_SendBuf(comport, buf, bytes_read) == -1) - err(-1, "error writing to serial"); - } + if (fwrite((unsigned char*) buf, bytes_read, 1, stdout) != 1) + err(-1, "error writing to stdout"); bytes_left -= bytes_read; } + /* - while(1){ + // not working - stdin breaks + while(1) + { int bytes_read=read(0,buf,sizeof(buf)); - if (stdout_instead_of_uart) - { - if (fwrite((unsigned char*) buf, bytes_read, 1, stdout) != 1) - err(-1, "error writing to stdout"); - } - else - { - if (RS232_SendBuf(comport, buf, bytes_read) == 1) - err(-1, "error writing to serial"); - } + if (fwrite((unsigned char*) buf, bytes_read, 1, stdout) != 1) + err(-1, "error writing to stdout"); } */ - if (!stdout_instead_of_uart) - RS232_CloseComport(comport); return 0; } |