Change select_fd args to microseconds
This commit is contained in:
parent
9a9abfc07c
commit
30a2f28f1a
4 changed files with 9 additions and 7 deletions
|
@ -640,8 +640,8 @@ int select_fd(int fd, unsigned timeout)
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(fd, &fds);
|
FD_SET(fd, &fds);
|
||||||
|
|
||||||
tv.tv_sec = timeout / 1000;
|
tv.tv_sec = timeout / 1000000;
|
||||||
tv.tv_usec = 1000 * (timeout % 1000);
|
tv.tv_usec = timeout % 1000000;
|
||||||
|
|
||||||
status = select(fd + 1, &fds, NULL, NULL, &tv);
|
status = select(fd + 1, &fds, NULL, NULL, &tv);
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
|
8
main.c
8
main.c
|
@ -33,14 +33,14 @@ void usage(FILE *fp)
|
||||||
"Options (-i, -f and/or -c are mandatory):\n"
|
"Options (-i, -f and/or -c are mandatory):\n"
|
||||||
" -a <ipaddr> IP address to assign to target device\n"
|
" -a <ipaddr> IP address to assign to target device\n"
|
||||||
" -A <ipaddr> IP address to assign to seleted interface\n"
|
" -A <ipaddr> IP address to assign to seleted interface\n"
|
||||||
" -B Blind mode (don't wait for NMRP responses)\n"
|
" -B Blind mode (don't wait for response packets)\n"
|
||||||
" -c <command> Command to run before (or instead of) TFTP upload\n"
|
" -c <command> Command to run before (or instead of) TFTP upload\n"
|
||||||
" -f <firmware> Firmware file\n"
|
" -f <firmware> Firmware file\n"
|
||||||
" -F <filename> Remote filename to use during TFTP upload\n"
|
" -F <filename> Remote filename to use during TFTP upload\n"
|
||||||
" -i <interface> Network interface directly connected to device\n"
|
" -i <interface> Network interface directly connected to device\n"
|
||||||
" -m <mac> MAC address of target device (xx:xx:xx:xx:xx:xx)\n"
|
" -m <mac> MAC address of target device (xx:xx:xx:xx:xx:xx)\n"
|
||||||
" -M <netmask> Subnet mask to assign to target device\n"
|
" -M <netmask> Subnet mask to assign to target device\n"
|
||||||
" -t <timeout> Timeout (in milliseconds) for regular messages\n"
|
" -t <timeout> Timeout (in milliseconds) for NMRP packets\n"
|
||||||
" -T <timeout> Time (seconds) to wait after successfull TFTP upload\n"
|
" -T <timeout> Time (seconds) to wait after successfull TFTP upload\n"
|
||||||
" -p <port> Port to use for TFTP upload\n"
|
" -p <port> Port to use for TFTP upload\n"
|
||||||
#ifdef NMRPFLASH_SET_REGION
|
#ifdef NMRPFLASH_SET_REGION
|
||||||
|
@ -133,7 +133,7 @@ int main(int argc, char **argv)
|
||||||
int c, val, max;
|
int c, val, max;
|
||||||
bool list = false, have_dest_mac = false;
|
bool list = false, have_dest_mac = false;
|
||||||
struct nmrpd_args args = {
|
struct nmrpd_args args = {
|
||||||
.rx_timeout = 200,
|
.rx_timeout = NMRPFLASH_DEF_RX_TIMEOUT * 1000,
|
||||||
.ul_timeout = 5 * 60 * 1000,
|
.ul_timeout = 5 * 60 * 1000,
|
||||||
.tftpcmd = NULL,
|
.tftpcmd = NULL,
|
||||||
.file_local = NULL,
|
.file_local = NULL,
|
||||||
|
@ -235,7 +235,7 @@ int main(int argc, char **argv)
|
||||||
if (c == 'p') {
|
if (c == 'p') {
|
||||||
args.port = val;
|
args.port = val;
|
||||||
} else if (c == 't') {
|
} else if (c == 't') {
|
||||||
args.rx_timeout = val;
|
args.rx_timeout = val * 1000;
|
||||||
} else if (c == 'T') {
|
} else if (c == 'T') {
|
||||||
args.ul_timeout = val * 1000;
|
args.ul_timeout = val * 1000;
|
||||||
}
|
}
|
||||||
|
|
2
nmrpd.h
2
nmrpd.h
|
@ -72,6 +72,8 @@
|
||||||
|
|
||||||
#define NMRPFLASH_SET_REGION
|
#define NMRPFLASH_SET_REGION
|
||||||
|
|
||||||
|
#define NMRPFLASH_DEF_RX_TIMEOUT 200
|
||||||
|
|
||||||
struct eth_hdr {
|
struct eth_hdr {
|
||||||
uint8_t ether_dhost[6];
|
uint8_t ether_dhost[6];
|
||||||
uint8_t ether_shost[6];
|
uint8_t ether_shost[6];
|
||||||
|
|
2
tftp.c
2
tftp.c
|
@ -315,7 +315,7 @@ int tftp_put(struct nmrpd_args *args)
|
||||||
const char *file_remote = args->file_remote;
|
const char *file_remote = args->file_remote;
|
||||||
char *val, *end;
|
char *val, *end;
|
||||||
bool rollover;
|
bool rollover;
|
||||||
unsigned rx_timeout = MAX(args->rx_timeout / 200, 1);
|
unsigned rx_timeout = MAX(args->rx_timeout / NMRPFLASH_DEF_RX_TIMEOUT, 1000);
|
||||||
|
|
||||||
sock = -1;
|
sock = -1;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue