Skip to content

Instantly share code, notes, and snippets.

@dwilkins
Created January 12, 2014 05:22
Show Gist options
  • Save dwilkins/8381277 to your computer and use it in GitHub Desktop.
Save dwilkins/8381277 to your computer and use it in GitHub Desktop.
Patch for avrdude to make rfcomm devices work again
Index: ser_posix.c
===================================================================
--- ser_posix.c (revision 1255)
+++ ser_posix.c (working copy)
@@ -315,6 +315,7 @@
static int ser_send(union filedescriptor *fd, unsigned char * buf, size_t buflen)
{
int rc;
+ int retries = 10;
unsigned char * p = buf;
size_t len = buflen;
@@ -344,6 +345,10 @@
while (len) {
rc = write(fd->ifd, p, (len > 1024) ? 1024 : len);
+ if (rc < 0 && errno == ENOTCONN && retries--) {
+ sleep(1);
+ continue;
+ }
if (rc < 0) {
fprintf(stderr, "%s: ser_send(): write error: %s\n",
progname, strerror(errno));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment