search for: ser_get_char

Displaying 15 results from an estimated 15 matches for "ser_get_char".

2010 Apr 19
1
Patch for the bestfortress driver 0.02
...; int len; int retry; + char ch; int checksum_ok, is_online=1, is_off, low_batt, trimming, boosting; for (retry = 0; retry < 5; ++retry) { upsflushin (0, 0, "\r "); upssend ("f\r"); + while (ser_get_char(upsfd, &ch, 0, UPSDELAY) > 0 && ch != '\n'); // response starts with \r\n + temp[2] = 0; do { - if (upsrecv (temp+2, sizeof temp - 2, ENDCHAR, IGNCHARS) <= 0) { + if ((len = upsrecv (temp+2, sizeof t...
2007 Dec 02
1
Driver bestfcom - Timing problem with Fortress LI1420
...??????? * "\r\n{Inverter: ? ? On}\r\n=>" @@ -190,10 +191,12 @@ ????????????????POLL_ALERT, alert_handler, 0, 20); ? ????????ser_send(upsfd, cmd); +???????sleep(UPSDELAY); ? ????????/* delete command echo up to \012 but no further */ ????????for (ch = '\0'; ch != '\012'; ser_get_char(upsfd, &ch, 0, 10)); ? +???????sleep(UPSDELAY); ????????/* get command response?*/ ????????ret = ser_get_line(upsfd, result, resultsize, '\015', "\012", 3, 0); ? @@ -741,7 +744,9 @@ ????????????????exit(EXIT_FAILURE); ????????} ? +???????sleep(UPSDELAY); ????????execute("...
2005 Nov 08
0
gcc4 noise
...eers to de-noise the code a bit? The easy way is to insert typecasts; the better way is to actually take care about signedness. -- Peter gcc -I../include -O -Wall -Wsign-compare -c -o everups.o everups.c everups.c: In function Code: everups.c:38: warning: pointer targets in passing argument 2 of ser_get_char differ in signedness everups.c: In function InitUpsType: everups.c:49: warning: pointer targets in passing argument 2 of ser_get_char differ in signedness everups.c: In function upsdrv_updateinfo: everups.c:96: warning: pointer targets in passing argument 2 of ser_get_char differ in signedness ever...
2006 Feb 09
6
gcc4 compiler warnings
Hi all! The following files emits warnings when compiled with gcc 4.0: al175.c bcmxcp_ser.c belkinunv.c cyberpower.c everups.c powercom.c solis.c All warnings seem to be of this variety: everups.c:38: warning: pointer targets in passing argument 2 of 'ser_get_char' differ in signedness I suggest that those who fiddles with those drivers fixes the warnings and verifies that it works afterwards. I can provide the complete buildlog if there's anyone that doesn't have access to a gcc4-equipped machine. /Nikke - prefers a noise free build output...
2008 Nov 06
0
[nut-commits] svn commit r1549 - in trunk: . drivers
...the UPS. See > docs/new-drivers.txt for an explanation why. Basically this will > only work if the driver is able > to keep up with the flow of data from the UPS and the select_read() > function in ser_get_line() > reads one character at a time. In that case, switching to > ser_get_char() is more reliable, > since that is not prone to losing data after reading ENDCHAR. What was I thinking? I completely missed the fact that the UPScode II driver sets the communication parameters to ICANON (Canonical Mode Input Processing), so the above is not an issue at all. There is a (...
2008 Oct 30
1
Adding debugging information in serial.c
In order to improve the diagnostics for serial connected devices, I would like to add the possibility to differentiate between errors and timeouts. For the ser_get_char() and ser_get_buf_len() we might do this by changing the return value. For the first, return value -1 would be an error, 0 a timeout and 1 success. The latter could return -1 on error, between 0 and (buflen-1) for a timeout and buflen for success. Unfortunately, the ser_get_line_alert() and...
2006 Nov 26
1
Patch for optiups to support Zinto D from ONLINE USV-Systeme AG
...TI_ZINTO) ) + { + /* If UPS is off, switch it on first */ + /* Online-UPS send only "2" when off, without "\r\n" */ + /* Therefore without power we cannot identify the ups */ + if ( optiquery( "AG" ) < 1 ) + { + ser_send( upsfd, "AG\r\n" ); + r = ser_get_char(upsfd, &_buf[0], 1, 0); + if ( r == 1 && _buf[0] == '2' ) + { + upslogx( LOG_WARNING, "ups was off, switched on" ); + optiquery( "Ct1" ); + optiquery( "Cu0000000" ); + sleep(12); + } + } + optiquery( "Om11" ); + optiqu...
2018 Mar 14
2
Interfacing with Siemens SITOP UPS500S
Hello all, For an upcoming project I will have to interface with a 24V DC UPS from Siemens (full name: Siemens SITOP UPS500S, manufacturer nr 6EP1933-2EC41). As this device is not listed in the compatibility list, I will have to write my own driver. I already found out, that the UPS has a serial-over-USB interface (USB full-speed, 12 MBps), using an FTDI chip. Over this serial port, it will
2018 Mar 14
0
Interfacing with Siemens SITOP UPS500S
...ous stream of data without sending a query command. For a query/response example, ivtscd.c is relatively straightforward to understand. Given the fixed-length strings and unambiguity of the commands, you might want a loop like the following: ser_flush_in() while(!done && !timed_out) { ser_get_char() // append to buffer check for match check for timeout } One thing that may be useful while waiting for hardware is to embed a test harness in the code. We don't have much of a standard for this, but as long as the code doesn't turn into spaghetti, feel free to use something l...
2011 May 19
2
Scheduling NUT 2.6.1
Fellows, time has come for a new NUT release: I'm planning on 2.6.1 next week (max Friday 27), and I'm currently processing remaining patches. If you have some more on your side, please send in. cheers, Arnaud -- Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/ Debian Developer -
2008 Jul 10
2
[PATCH] tripplite driver updates
...gned i * return: # of chars in buf, excluding terminating \0 */ static int send_cmd(const char *str, char *buf, size_t len) { - char c; - int ret; + unsigned char c; + int ret = 0; size_t i = 0; ser_send(upsfd, str); if (!len || !buf) - return -1; + goto out; for (;;) { ret = ser_get_char(upsfd, &c, SER_WAIT_SEC, SER_WAIT_USEC); if (ret == -1) - return -1; + goto out; if (c == ENDCHAR) break; } do { ret = ser_get_char(upsfd, &c, SER_WAIT_SEC, SER_WAIT_USEC); if (ret == -1) - return -1; + goto out; if (c == IGNCHAR || c == ENDCHAR) continu...
2011 Oct 03
0
patch: Fix [-Wunused-but-set-variable]
...v(int upsfd, u_char * u_short Pos=0; u_char Retry=0; int recv; - shut_data_t sdata; upsdebugx (4, "entering shut_packet_recv (%i)", datalen); @@ -687,7 +686,6 @@ int shut_packet_recv(int upsfd, u_char * /* if(serial_read (SHUT_TIMEOUT, &Start[0]) > 0) */ if(ser_get_char(upsfd, &Start[0], SHUT_TIMEOUT/1000, 0) > 0) { - sdata.shut_pkt.bType = Start[0]; if(Start[0]==SHUT_SYNC) { upsdebugx (4, "received SYNC token"); @@ -702,7 +700,6 @@ int shut_packet_recv(int upsfd, u_char * { upsdebug_hex(4, "Receive", Start,...
2005 Dec 19
0
new(er) SEC driver.
...if (len < 4) { /* min length */ upsdebugx(SEC_LOG_LOWLEVEL, " invalid buffer length %d", len); return -2; } /* look for the startchar */ *buf = '\0'; for (i=0; i<30 && (*buf != SEC_MSG_STARTCHAR); i++) { /* up to 30 characters, OR 3 seconds */ if (ser_get_char(fd, buf, 0, 100000)<0) /* failed to read */ *buf = '\0'; } if (*buf != SEC_MSG_STARTCHAR) { upsdebugx(SEC_LOG_LOWLEVEL, " FAILED to find start char %c",SEC_MSG_STARTCHAR); return -2; } /* we found a msg, which one? */ upsdebugx(SEC_LOG_LOWLEVEL, &qu...
2011 Oct 03
2
patch: Replace many usleep and some sleep calls with nanosleep
...*cmd, char ser_send(upsfd, "%s", cmd); /* Give the UPS some time to chew on what we just sent */ - usleep(50000); + struct timespec delay = {0, 50e6}; nanosleep(&delay, NULL); /* delete command echo up to \012 but no further */ for (ch = '\0'; ch != '\012'; ser_get_char(upsfd, &ch, 0, 10000)); @@ -458,18 +458,19 @@ void upsdrv_help(void) static void sync_serial(void) { char buffer[10]; + struct timespec delay = {UPSDELAY, 0}; ser_flush_in(upsfd, "", 1); ser_send(upsfd, "\r"); - sleep(UPSDELAY); + nanosleep(&delay, NULL);...
2008 Dec 24
1
Driver removal notification: al175
Hi Kirill, just to notify you that your al175 driver is being removed from the NUT tree, as of 2.4.0-pre1. if you wish to see it entering the tree again, please contact the Development mailing list to talk about it. Merry Christmas and happy New Year. Arnaud -- Linux / Unix Expert R&D - Eaton - http://www.eaton.com/mgeops Network UPS Tools (NUT) Project Leader -