Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usbhid-ups changes: more resiliant w/failures; scales Tripp Lite SMART1500LCDT #122

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion drivers/al175.c
Original file line number Diff line number Diff line change
Expand Up @@ -1261,12 +1261,14 @@ void upsdrv_makevartable(void)
{
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B9600);

ser_disable_flow_control();

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/apcsmart-old.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ void upsdrv_makevartable(void)
addvar(VAR_VALUE, "advorder", "Enable advanced shutdown control");
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
char *cable;

Expand All @@ -1428,6 +1428,8 @@ void upsdrv_initups(void)

/* make sure we wake up if the UPS sends alert chars to us */
extrafd = upsfd;

return 1;
}

void upsdrv_help(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/apcsmart.c
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,7 @@ void upsdrv_help(void)
);
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
char *val;
apc_vartab_t *ptr;
Expand All @@ -2030,6 +2030,8 @@ void upsdrv_initups(void)
/* fill length values */
for (ptr = apc_vartab; ptr->name; ptr++)
ptr->nlen0 = strlen(ptr->name) + 1;

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/apcupsd-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ void upsdrv_makevartable(void)
{
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
char *p;
struct hostent *h;
Expand All @@ -283,6 +283,8 @@ void upsdrv_initups(void)
/* TODO: add IPv6 support */
host.sin_family=AF_INET;
host.sin_port=htons(port);

return 1;
}

void upsdrv_cleanup(void)
Expand Down
2 changes: 1 addition & 1 deletion drivers/bcmxcp_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ void send_write_command(unsigned char *command, int command_length);
int get_answer(unsigned char *data, unsigned char command);
int command_read_sequence(unsigned char command, unsigned char *data);
int command_write_sequence(unsigned char *command, int command_length, unsigned char *answer);
void upsdrv_initups(void);
int upsdrv_initups(void);
void upsdrv_cleanup(void);
void upsdrv_reconnect(void);
void upsdrv_comm_good(void);
Expand Down
4 changes: 3 additions & 1 deletion drivers/bcmxcp_ser.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,12 @@ void pw_comm_setup(const char *port)
fatalx(EXIT_FAILURE, "Can't connect to the UPS on port %s!\n", port);
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsfd = ser_open(device_path);
pw_comm_setup(device_path);

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/bcmxcp_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,11 @@ void upsdrv_comm_good(void)
nutusb_comm_good();
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsdev = nutusb_open("USB");

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/belkin.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void upsdrv_makevartable(void)
}

/* prep the serial port */
void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B2400);
Expand All @@ -478,6 +478,8 @@ void upsdrv_initups(void)
sleep(1);

ser_flush_io(upsfd);

return 1;
}

void upsdrv_initinfo(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/belkinunv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ void upsdrv_makevartable(void)
}

/* prep the serial port */
void upsdrv_initups(void)
int upsdrv_initups(void)
{
/* If '-x wait' or '-x wait=<level>' option given, branch into
standalone behavior. */
Expand All @@ -1316,6 +1316,8 @@ void upsdrv_initups(void)
}

belkin_nut_open_tty();

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 2 additions & 2 deletions drivers/bestfcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ void upsdrv_init_fc(const char *fcstring)
fc.valid = 1;
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
char rstring[256];

Expand All @@ -754,7 +754,7 @@ void upsdrv_initups(void)
upsdrv_init_fc(rstring);
}

return;
return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/bestfortress.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ struct {
{NULL, B1200},
};

void upsdrv_initups(void)
int upsdrv_initups(void)
{
speed_t speed = B1200;

Expand All @@ -447,6 +447,8 @@ void upsdrv_initups(void)
/* the upsh handlers can't be done here, as they get initialized
* shortly after upsdrv_initups returns to main.
*/

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 2 additions & 2 deletions drivers/bestuferrups.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static void setup_serial(void)
}


void upsdrv_initups ()
int upsdrv_initups ()
{
char temp[256], fcstring[512];

Expand Down Expand Up @@ -488,7 +488,7 @@ void upsdrv_initups ()
}

fc.valid = 1;
return;
return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/bestups.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,12 @@ void upsdrv_makevartable(void)
addvar(VAR_VALUE, "ID", "Force UPS ID response string");
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B2400);

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/blazer_ser.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void upsdrv_makevartable(void)
}


void upsdrv_initups(void)
int upsdrv_initups(void)
{
#ifndef TESTING
const struct {
Expand Down Expand Up @@ -183,6 +183,8 @@ void upsdrv_initups(void)
usleep(100000);
#endif
blazer_initups();

return 1;
}


Expand Down
8 changes: 5 additions & 3 deletions drivers/blazer_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ int blazer_command(const char *cmd, char *buf, size_t buflen)
int ret;

if (udev == NULL) {
ret = usb->open(&udev, &usbdevice, reopen_matcher, NULL);
ret = usb->open(&udev, &usbdevice, reopen_matcher, NULL, 1);

if (ret < 1) {
return ret;
Expand Down Expand Up @@ -513,7 +513,7 @@ void upsdrv_makevartable(void)
}


void upsdrv_initups(void)
int upsdrv_initups(void)
{
#ifndef TESTING
const struct {
Expand Down Expand Up @@ -589,7 +589,7 @@ void upsdrv_initups(void)
/* link the matchers */
regex_matcher->next = &device_matcher;

ret = usb->open(&udev, &usbdevice, regex_matcher, NULL);
ret = usb->open(&udev, &usbdevice, regex_matcher, NULL, 1);
if (ret < 0) {
fatalx(EXIT_FAILURE,
"No supported devices found. Please check your device availability with 'lsusb'\n"
Expand Down Expand Up @@ -633,6 +633,8 @@ void upsdrv_initups(void)
}
#endif
blazer_initups();

return 1;
}


Expand Down
4 changes: 3 additions & 1 deletion drivers/clone-outlet.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void upsdrv_makevartable(void)
}


void upsdrv_initups(void)
int upsdrv_initups(void)
{
char buf[SMALLBUF];
const char *val;
Expand All @@ -405,6 +405,8 @@ void upsdrv_initups(void)
prefix.status = xstrdup(buf);

extrafd = upsfd = sstate_connect();

return 1;
}


Expand Down
4 changes: 3 additions & 1 deletion drivers/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,11 @@ void upsdrv_makevartable(void)
}


void upsdrv_initups(void)
int upsdrv_initups(void)
{
extrafd = upsfd = sstate_connect();

return 1;
}


Expand Down
4 changes: 3 additions & 1 deletion drivers/dummy-ups.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void upsdrv_makevartable(void)
{
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
/* check the running mode... */
if (strchr(device_path, '@'))
Expand All @@ -234,6 +234,8 @@ void upsdrv_initups(void)
mode = MODE_DUMMY;
dstate_setinfo("driver.parameter.mode", "dummy");
}

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/etapro.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,14 +350,16 @@ upsdrv_makevartable(void)
{
}

void
int
upsdrv_initups(void)
{
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B1200);

ser_set_dtr(upsfd, 0);
ser_set_rts(upsfd, 1);

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/everups.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,15 @@ void upsdrv_makevartable(void)
{
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B300);

init_serial();
InitUpsType();

return 1;
}

void upsdrv_cleanup(void)
Expand Down
3 changes: 2 additions & 1 deletion drivers/gamatronic.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ void setup_serial(const char *port)
printf("Connected to UPS on %s baudrate: %d\n",port, baud_rates[i].name);
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsfd = ser_open(device_path);
setup_serial(device_path);
Expand Down Expand Up @@ -401,6 +401,7 @@ void upsdrv_initups(void)
*/


return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/genericups.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ void upsdrv_makevartable(void)
addvar(VAR_VALUE, "sdtime", "Hold time for shutdown value (seconds)");
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
struct termios tio;
char *v;
Expand Down Expand Up @@ -329,6 +329,8 @@ void upsdrv_initups(void)
if (ioctl(upsfd, TIOCMSET, &upstab[upstype].line_norm)) {
fatal_with_errno(EXIT_FAILURE, "ioctl TIOCMSET");
}

return 1;
}

void upsdrv_cleanup(void)
Expand Down
4 changes: 3 additions & 1 deletion drivers/isbmex.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@ void upsdrv_makevartable(void)
{
}

void upsdrv_initups(void)
int upsdrv_initups(void)
{
upsfd = ser_open(device_path);
ser_set_speed(upsfd, device_path, B9600);

return 1;
}

void upsdrv_cleanup(void)
Expand Down
Loading