aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Vymetálek <pavel@vym.cz>2020-04-06 10:38:31 +0200
committerPavel Vymetálek <pavel@vym.cz>2020-04-06 10:38:31 +0200
commit9cc1f6571b3fa961a45ef7320b66e12524fc09de (patch)
treefab2e3969e1b32fe9b8b3cd29f4938faba2ed6a8
parent3c8188b0070131a5b0eddb9a57dd54722d965b4c (diff)
downloadsercp-pc-9cc1f6571b3fa961a45ef7320b66e12524fc09de.tar.gz
Fixed sending and progressbar for files smaller than 256 bytes
-rw-r--r--CHANGELOG4
-rw-r--r--TODO6
-rw-r--r--sercp.c15
3 files changed, 17 insertions, 8 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 2c3b436..c77fc6e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,7 @@
+2020-04-06 v0.3.3 fixed progressbar for files smaller than 256 bytes
+2020-04-05 v0.3.2 changes for __APPLE__ and BSD - still not work on aplle :(
2020-04-03 v0.3.1 fixed complicated interrupting by ctrl-c
2019-03-26 v0.3.0 add support for time/date handling
2019-03-16 v0.2.3 fixed serial port setup to work on Mac
2019-03-09 v0.2.2 remove unnecessary waiting after last block
-2019-03-02 versions before this date was unreleased \ No newline at end of file
+2019-03-02 versions before this date was unreleased
diff --git a/TODO b/TODO
index 0927f36..f8ac68e 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,10 @@
+2020-04-05
+ + for short files < 256 bytes does not work the progressbar - underflow counter
+ - listing of enumerated serial ports - linux, win, mac
2020-04-04
- add test serial line - show CTS, RTS lines state
2019-09-03
- - fix progressbar for files smaller than 16kB
-
+ + fix progressbar for files smaller than 16kB
2019-03-16
+ add support for handling time/date of files
diff --git a/sercp.c b/sercp.c
index 07054f4..a044639 100644
--- a/sercp.c
+++ b/sercp.c
@@ -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;