mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-09-27 14:35:27 +00:00
Support for Arduino auto-reset:
* serial.h, ser_avrdoper.c, ser_posix.c, ser_win32.c: Added serial_device.set_dtr_rts implementations. * arduino.c, stk500.c, stk500.h: Call serial_set_dtr_rts() to reset Arduino board before program upload. Inspired by patch #6866, resolves bug #26703 git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@845 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
32
ser_posix.c
32
ser_posix.c
@@ -32,6 +32,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -210,6 +211,36 @@ net_open(const char *port, union filedescriptor *fdp)
|
||||
fdp->ifd = fd;
|
||||
}
|
||||
|
||||
|
||||
static int ser_set_dtr_rts(union filedescriptor *fdp, int is_on)
|
||||
{
|
||||
unsigned int ctl;
|
||||
int r;
|
||||
|
||||
r = ioctl(fdp->ifd, TIOCMGET, &ctl);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCMGET\")");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_on) {
|
||||
/* Clear DTR and RTS */
|
||||
ctl &= ~(TIOCM_DTR | TIOCM_RTS);
|
||||
}
|
||||
else {
|
||||
/* Set DTR and RTS */
|
||||
ctl |= (TIOCM_DTR | TIOCM_RTS);
|
||||
}
|
||||
|
||||
r = ioctl(fdp->ifd, TIOCMSET, &ctl);
|
||||
if (r < 0) {
|
||||
perror("ioctl(\"TIOCMSET\")");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ser_open(char * port, long baud, union filedescriptor *fdp)
|
||||
{
|
||||
int rc;
|
||||
@@ -455,6 +486,7 @@ struct serial_device serial_serdev =
|
||||
.send = ser_send,
|
||||
.recv = ser_recv,
|
||||
.drain = ser_drain,
|
||||
.set_dtr_rts = ser_set_dtr_rts,
|
||||
.flags = SERDEV_FL_CANSETSPEED,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user