Giter Site home page Giter Site logo

mynewt_serial_uploader's People

Contributors

mkiiskila avatar samandersonpax avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

mynewt_serial_uploader's Issues

Valid Return Code on Errors

Hello, I don't currently have write access, but the current code does not return proper error codes on failures. I've added a small patch file below. It would be nice to get this merged in for use in automated tests.

index e1d9dd0..0bcfdf6 100755
--- a/serial_upload.c
+++ b/serial_upload.c
@@ -506,6 +506,7 @@ main(int argc, char **argv)
 {
     HANDLE fd;
     int rc;
+    int ret = EXIT_SUCCESS;

     cmdname = argv[0];
     state.imgchunk = 512;
@@ -535,9 +536,13 @@ main(int argc, char **argv)
     rc = echo_ctl(0);
     if (rc == 0) {
         rc = img_upload();
+    } else {
+        ret = EXIT_FAILURE;
     }
     if (rc == 0) {
         rc = reset_device();
+    } else {
+        ret = EXIT_FAILURE;
     }
 #if 0
     if (echo_ctl(1)) {
@@ -547,5 +552,5 @@ main(int argc, char **argv)
     free(state.file);
     fflush(stderr);
     fflush(stdout);
-    return 0;
+    return ret;
 }

POSIX Baud Rate Values

Hi, I ran into an issue running this on Alpine Linux. The cfsetspeed() call should take the POSIX portable bit defines (B#####). A patch is provided below.

index e553cfd..b648f03 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,7 @@ tinycbor/src/%.c:

 serial_upload: $(SRCS) serial_upload.h
 	@echo serial_upload
-	cc -o serial_upload -ggdb -Wall -I tinycbor/src -I . $(SRCS)
+	$(CC) -o serial_upload -ggdb -Wall -I tinycbor/src -I . $(SRCS)

 clean:
 	rm serial_upload
diff --git a/serial_upload_unix.c b/serial_upload_unix.c
index 9e83884..d169ec8 100644
--- a/serial_upload_unix.c
+++ b/serial_upload_unix.c
@@ -24,6 +24,7 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/time.h>
+#include <sys/ioctl.h>
 #include <arpa/inet.h>
 #include <errno.h>

@@ -64,9 +65,43 @@ port_setup(int fd, unsigned long speed)
       ECHONL | ECHOCTL | ECHOPRT | ECHOKE | FLUSHO | NOFLSH |
       TOSTOP | PENDIN | IEXTEN);

+#if defined(__posix__)
+    speed_t sp;
+    switch(speed) {
+      case 921600:
+        sp = B921600;
+        break;
+      case 460800:
+        sp = B460800;
+        break;
+      case 230400:
+        sp = B230400;
+        break;
+      case 115200:
+        sp = B115200;
+        break;
+      case 57600:
+        sp = B57600;
+        break;
+      case 38400:
+        sp = B38400;
+        break;
+      case 19200:
+        sp = B19200;
+        break;
+      case 9600:
+        sp = B9600;
+        break;
+      default:
+        sp = B115200;
+        break;
+    }
+    rc = cfsetspeed(&tios, sp);
+#elif defined(__APPLE__)
     rc = cfsetspeed(&tios, (speed_t)speed);
+#endif
     if (rc < 0) {
-        fprintf(stderr, "%s: cfsetspeed(%lu) failed\n", cmdname, speed);
+        fprintf(stderr, "%s: cfsetspeed(%lu) failed: %s\n", cmdname, speed, strerror(errno));
         return rc;
     }

should put serial port to low latency mode on linux

At the moment it does not happen automatically, and by default Linux serial ports are slow pollers.
So the user has to either scriptify this or set it manually.
Basically this setting:
cat /sys/bus/usb-serial/devices/ttyUSB0/latency_timer 16
echo 1 > /sys/bus/usb-serial/devices/ttyUSB0/latency_timer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.