diff options
author | Pavel Vymetálek <pavel@vym.cz> | 2020-04-06 10:38:31 +0200 |
---|---|---|
committer | Pavel Vymetálek <pavel@vym.cz> | 2020-04-06 10:38:31 +0200 |
commit | 9cc1f6571b3fa961a45ef7320b66e12524fc09de (patch) | |
tree | fab2e3969e1b32fe9b8b3cd29f4938faba2ed6a8 /sercp.c | |
parent | 3c8188b0070131a5b0eddb9a57dd54722d965b4c (diff) | |
download | sercp-pc-9cc1f6571b3fa961a45ef7320b66e12524fc09de.tar.gz |
Fixed sending and progressbar for files smaller than 256 bytes
Diffstat (limited to 'sercp.c')
-rw-r--r-- | sercp.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -65,7 +65,7 @@ #define FALSE 0 #define true 1 #define TRUE 1 -const char* _version = "v0.3.2"; +const char* _version = "v0.3.3"; // SERIAL FILE *tapout_fd = NULL; int is_outfile = 0; @@ -515,7 +515,7 @@ void sercpSend(void) { uint8_t num_blocks = 0; ssize_t odeslano; uint32_t len_sent; - uint16_t sent_size; + uint16_t send_size; uint32_t overall_sent; #ifdef _WIN32 unsigned long ulNumBytes; @@ -595,14 +595,18 @@ void sercpSend(void) { while (file_len) { len = fread(buff, 1, 16384, tap_fd); // read 16kiB from file p_buff = buff; - sent_size = 256; + if (len > 256) { + send_size = 256; + } else { + send_size = len; + } len_sent = len; while (len_sent) { #ifdef _WIN32 WriteFile(serial_fd, (void*)p_buff, sent_size, &ulNumBytes, NULL); odeslano = (size_t)ulNumBytes; #else - odeslano = write (serial_fd, (void*)p_buff, sent_size); + odeslano = write (serial_fd, (void*)p_buff, send_size); if (tcdrain(serial_fd) == -1) { perror("tcdrain err2: "); return; @@ -612,7 +616,7 @@ void sercpSend(void) { overall_sent += odeslano; len_sent -= odeslano; if (len_sent < 256) { - sent_size = len_sent; + send_size = len_sent; } DoProgress(overall_sent, st.st_size, PROGRESS_PERCENT); } @@ -708,6 +712,7 @@ int OpenUart() { cfmakeraw(&newtio); cfsetspeed(&newtio, baud_rate); #if defined (__APPLE__) || defined (BSD) + // pro jabkace | CNEW_RTSCTS newtio.c_cflag = CS8 | CLOCAL | CREAD | CCTS_OFLOW | CRTS_IFLOW; // CSTOPB - two stop bits NOT #else newtio.c_cflag = CS8 | CLOCAL | CREAD | CRTSCTS; |