c9469b64fc3933d0565ffba8a45be8a39df6b927
Stefan Schuermans cleanup file headers after...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c   1) /* BlinkenLib
Stefan Schuermans update email address of author

Stefan Schuermans authored 10 years ago

BlinkenLib/BlinkenOutputWin.c   2)    Copyright 2004-2014 Stefan Schuermans <stefan@schuermans.info>
Stefan Schuermans cleanup file headers after...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c   3)    Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html
BlinkenLib/BlinkenOutputWin.c   4)    a blinkenarea.org project */
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c              5) 
BlinkenOutputWin.c              6) #include <fcntl.h>
BlinkenOutputWin.c              7) #include <stdlib.h>
BlinkenOutputWin.c              8) #include <stdio.h>
BlinkenOutputWin.c              9) #include <string.h>
BlinkenOutputWin.c             10) #include <winsock2.h>
BlinkenOutputWin.c             11) #include <windows.h>
BlinkenOutputWin.c             12) 
Christian Heimke BlinkenLib v.0.5.5 (2008-03...

Christian Heimke authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  13) #include <BlinkenLib/BlinkenLib.h>
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             14) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  15) // get serial settings from text
BlinkenLib/BlinkenOutputWin.c  16) static int serial_settings_parse(char *str)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             17) {
BlinkenOutputWin.c             18)   int baud, data, stop;
BlinkenOutputWin.c             19)   char parity;
BlinkenOutputWin.c             20)   int set = 0;
BlinkenOutputWin.c             21) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  22)   // split and parse settings string
BlinkenLib/BlinkenOutputWin.c  23)   if (sscanf(str, "%i,%c,%i,%i", &baud, &parity, &data, &stop) != 4)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             24)     return 0;
BlinkenOutputWin.c             25) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  26)   // baud rate
BlinkenLib/BlinkenOutputWin.c  27)   if (baud != 300 &&
BlinkenLib/BlinkenOutputWin.c  28)       baud != 600 &&
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             29)       baud != 1200 &&
BlinkenOutputWin.c             30)       baud != 2400 &&
BlinkenOutputWin.c             31)       baud != 4800 &&
BlinkenOutputWin.c             32)       baud != 9600 &&
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  33)       baud != 19200 && baud != 38400 && baud != 57600 && baud != 115200) {
BlinkenLib/BlinkenOutputWin.c  34)     printf("illegal baudrate: %d\n", baud);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             35)     return 0;
BlinkenOutputWin.c             36)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  37)   // parity
BlinkenLib/BlinkenOutputWin.c  38)   if (parity != 'n' && parity != 'N' &&
BlinkenLib/BlinkenOutputWin.c  39)       parity != 'e' && parity != 'E' && parity != 'o' && parity != 'O') {
BlinkenLib/BlinkenOutputWin.c  40)     printf("invalid parity: %c\n", parity);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             41)     return 0;
BlinkenOutputWin.c             42)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  43)   // data bits
BlinkenLib/BlinkenOutputWin.c  44)   if (data != 5 && data != 6 && data != 7 && data != 8) {
BlinkenLib/BlinkenOutputWin.c  45)     printf("illegal number of data bits: %d\n", data);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             46)     return 0;
BlinkenOutputWin.c             47)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  48)   // stop bits
BlinkenLib/BlinkenOutputWin.c  49)   if (stop != 1 && stop == 2) {
BlinkenLib/BlinkenOutputWin.c  50)     printf("illegal number of stop bits: %d\n", stop);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             51)     return 0;
BlinkenOutputWin.c             52)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  53)   // success
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             54)   return 1;
BlinkenOutputWin.c             55) }
BlinkenOutputWin.c             56) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  57) // set serial settings for fd
BlinkenLib/BlinkenOutputWin.c  58) static int serial_settings_set(HANDLE hDev, char *settings)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             59) {
BlinkenOutputWin.c             60)   DCB PortDcb;
BlinkenOutputWin.c             61)   COMMTIMEOUTS CommTimeouts;
BlinkenOutputWin.c             62) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  63)   // set serial parameters
BlinkenLib/BlinkenOutputWin.c  64)   if (!GetCommState(hDev, &PortDcb)) {
BlinkenLib/BlinkenOutputWin.c  65)     printf("error getting device comm state: error %u\n", GetLastError());
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             66)     return 0;
BlinkenOutputWin.c             67)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  68)   if (!BuildCommDCB(hDev, &PortDcb)) {
BlinkenLib/BlinkenOutputWin.c  69)     printf("error building comm state: error %u\n", GetLastError());
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             70)     return 0;
BlinkenOutputWin.c             71)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  72)   if (!SetCommState(hDev, &PortDcb)) {
BlinkenLib/BlinkenOutputWin.c  73)     printf("error setting device comm state: error %u\n", GetLastError());
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             74)     return 0;
BlinkenOutputWin.c             75)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  76)   // set timeout parameters
BlinkenLib/BlinkenOutputWin.c  77)   // maximum time between arrival of two characters: 10 ms
BlinkenLib/BlinkenOutputWin.c  78)   // if this time elapses, read command will return even if buffer is not
BlinkenLib/BlinkenOutputWin.c  79)   // filled completely
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             80)   CommTimeouts.ReadIntervalTimeout = 10;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  81)   // disable read timeouts
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             82)   CommTimeouts.ReadTotalTimeoutConstant = 0;
BlinkenOutputWin.c             83)   CommTimeouts.ReadTotalTimeoutMultiplier = 0;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  84)   // disable write timeouts
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             85)   CommTimeouts.WriteTotalTimeoutConstant = 0;
BlinkenOutputWin.c             86)   CommTimeouts.WriteTotalTimeoutMultiplier = 0;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  87)   if (!SetCommTimeouts(hDev, &CommTimeouts)) {
BlinkenLib/BlinkenOutputWin.c  88)     printf("error setting device timeout parameters: error %u\n",
BlinkenLib/BlinkenOutputWin.c  89)            GetLastError());
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             90)     return 0;
BlinkenOutputWin.c             91)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  92)   // success
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c             93)   return 1;
BlinkenOutputWin.c             94) }
BlinkenOutputWin.c             95) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c  96) // receive frames from socket and output them
BlinkenLib/BlinkenOutputWin.c  97) // hDev may be INVALID_HANDLE_VALUE for not doing anything with device
BlinkenLib/BlinkenOutputWin.c  98) // returns error code (not for device-errors, 0 for success)
BlinkenLib/BlinkenOutputWin.c  99) static int recv_and_out(SOCKET udpSocket, HANDLE hDev,
BlinkenLib/BlinkenOutputWin.c 100)                         int *p_device_output_active,
BlinkenLib/BlinkenOutputWin.c 101)                         unsigned int format_change,
BlinkenLib/BlinkenOutputWin.c 102)                         unsigned int format_height, unsigned int format_width,
BlinkenLib/BlinkenOutputWin.c 103)                         unsigned int format_channels,
BlinkenLib/BlinkenOutputWin.c 104)                         unsigned int format_colors, etBlinkenProto proto,
BlinkenLib/BlinkenOutputWin.c 105)                         int use_msecs, unsigned int msecs,
BlinkenLib/BlinkenOutputWin.c 106)                         int is_serial_device)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            107) {
BlinkenOutputWin.c            108)   fd_set readFds, errFds;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 109)   stBlinkenFrame *pFrame;
BlinkenLib/BlinkenOutputWin.c 110)   char buffer[65536];   // 64kB is more than maximum UDP size
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            111)   int len, dev_eof;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 112)   struct timeval timeout, *p_timeout;
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            113)   DWORD DevWrLen, Err, start, end;
BlinkenOutputWin.c            114)   COMSTAT ComStat;
BlinkenOutputWin.c            115) 
BlinkenOutputWin.c            116)   dev_eof = 0;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 117)   for (;;) {
BlinkenLib/BlinkenOutputWin.c 118)     // wait for next frame
BlinkenLib/BlinkenOutputWin.c 119)     FD_ZERO(&readFds);
BlinkenLib/BlinkenOutputWin.c 120)     FD_SET(udpSocket, &readFds);
BlinkenLib/BlinkenOutputWin.c 121)     FD_ZERO(&errFds);
BlinkenLib/BlinkenOutputWin.c 122)     FD_SET(udpSocket, &errFds);
BlinkenLib/BlinkenOutputWin.c 123)     if (use_msecs)      // timeout
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            124)     {
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 125)       start = GetTickCount();
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            126)       timeout.tv_sec = msecs / 1000;
BlinkenOutputWin.c            127)       timeout.tv_usec = msecs % 1000 * 1000;
BlinkenOutputWin.c            128)       p_timeout = &timeout;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 129)     } else
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            130)       p_timeout = NULL;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 131)     if (select(0, &readFds, NULL, &errFds, p_timeout) < 0)      // error
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            132)     {
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 133)       printf("error during select: %s\n", strerror(errno));
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            134)       return -1;
BlinkenOutputWin.c            135)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 136)     // error on socket
BlinkenLib/BlinkenOutputWin.c 137)     if (FD_ISSET(udpSocket, &errFds)) {
BlinkenLib/BlinkenOutputWin.c 138)       printf("error on socket\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            139)       return -1;
BlinkenOutputWin.c            140)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 141)     // received frame
BlinkenLib/BlinkenOutputWin.c 142)     if (FD_ISSET(udpSocket, &readFds)) {
BlinkenLib/BlinkenOutputWin.c 143)       // fetch data
BlinkenLib/BlinkenOutputWin.c 144)       len = recv(udpSocket, buffer, sizeof(buffer), 0);
BlinkenLib/BlinkenOutputWin.c 145)       if (len < 0) {
BlinkenLib/BlinkenOutputWin.c 146)         printf("could not read from socket\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            147)         return -1;
BlinkenOutputWin.c            148)       }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 149)       if (len == 0)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            150)         return -1;
BlinkenOutputWin.c            151) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 152)       // get frame from data
BlinkenLib/BlinkenOutputWin.c 153)       pFrame = BlinkenFrameFromNetwork(buffer, len, NULL);
BlinkenLib/BlinkenOutputWin.c 154)       if (pFrame != NULL) {
BlinkenLib/BlinkenOutputWin.c 155)         // change format
BlinkenLib/BlinkenOutputWin.c 156)         if (format_change)
BlinkenLib/BlinkenOutputWin.c 157)           BlinkenFrameResize(pFrame, format_height, format_width,
BlinkenLib/BlinkenOutputWin.c 158)                              format_channels, format_colors - 1);
BlinkenLib/BlinkenOutputWin.c 159) 
BlinkenLib/BlinkenOutputWin.c 160)         // create output data from frame
BlinkenLib/BlinkenOutputWin.c 161)         len = BlinkenFrameToNetwork(pFrame, proto, buffer, sizeof(buffer));
BlinkenLib/BlinkenOutputWin.c 162) 
BlinkenLib/BlinkenOutputWin.c 163)         // free frame
BlinkenLib/BlinkenOutputWin.c 164)         BlinkenFrameFree(pFrame);
BlinkenLib/BlinkenOutputWin.c 165) 
BlinkenLib/BlinkenOutputWin.c 166)         // output data to device
BlinkenLib/BlinkenOutputWin.c 167)         if (hDev != INVALID_HANDLE_VALUE && len > 0) {
BlinkenLib/BlinkenOutputWin.c 168)           if (!WriteFile(hDev, buffer, len, &DevWrLen, NULL)
BlinkenLib/BlinkenOutputWin.c 169)               || (int)DevWrLen != len) {
BlinkenLib/BlinkenOutputWin.c 170)             if (*p_device_output_active)
BlinkenLib/BlinkenOutputWin.c 171)               printf("error writing to device: error %lu\n", GetLastError());
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            172)             break;
BlinkenOutputWin.c            173)           }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 174)           // message: output to device was restarted
BlinkenLib/BlinkenOutputWin.c 175)           if (!*p_device_output_active)
BlinkenLib/BlinkenOutputWin.c 176)             printf("restarted output to device...\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            177)           *p_device_output_active = 1;
BlinkenOutputWin.c            178)         }
BlinkenOutputWin.c            179)       }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 180)     }
BlinkenLib/BlinkenOutputWin.c 181)     // get state of serial device
BlinkenLib/BlinkenOutputWin.c 182)     if (hDev != INVALID_HANDLE_VALUE && is_serial_device) {
BlinkenLib/BlinkenOutputWin.c 183)       ClearCommError(hDev, &Err, &ComStat);
BlinkenLib/BlinkenOutputWin.c 184)       // reception error
BlinkenLib/BlinkenOutputWin.c 185)       if (Err & (CE_BREAK | CE_FRAME | CE_OVERRUN | CE_RXOVER | CE_RXPARITY)) {
BlinkenLib/BlinkenOutputWin.c 186)         if (*p_device_output_active)
BlinkenLib/BlinkenOutputWin.c 187)           printf("error reading from device (comm err=%X)\n", Err);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            188)         break;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 189)       }
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            190)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 191)     // using time limit
BlinkenLib/BlinkenOutputWin.c 192)     if (use_msecs) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            193)       unsigned int msec;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 194)       // get time elapsed
BlinkenLib/BlinkenOutputWin.c 195)       end = GetTickCount();
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            196)       msec = end - start;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 197)       // more than rest of timeout (or exact match)
BlinkenLib/BlinkenOutputWin.c 198)       if (msec >= msecs)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            199)         break;
BlinkenOutputWin.c            200)       msecs -= msec;
BlinkenOutputWin.c            201)     }
BlinkenOutputWin.c            202) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 203)   }     // for( ; ; )
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            204) 
BlinkenOutputWin.c            205)   return 0;
BlinkenOutputWin.c            206) }
BlinkenOutputWin.c            207) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 208) // open device and output frames
BlinkenLib/BlinkenOutputWin.c 209) // returns error code (not for device-errors, 0 for success)
BlinkenLib/BlinkenOutputWin.c 210) static int open_and_output(SOCKET udpSocket, char *device,
BlinkenLib/BlinkenOutputWin.c 211)                            int *p_device_output_active,
BlinkenLib/BlinkenOutputWin.c 212)                            int serial_settings_change, char *serial_settings,
BlinkenLib/BlinkenOutputWin.c 213)                            unsigned int format_change,
BlinkenLib/BlinkenOutputWin.c 214)                            unsigned int format_height,
BlinkenLib/BlinkenOutputWin.c 215)                            unsigned int format_width,
BlinkenLib/BlinkenOutputWin.c 216)                            unsigned int format_channels,
BlinkenLib/BlinkenOutputWin.c 217)                            unsigned int format_colors, etBlinkenProto proto)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            218) {
BlinkenOutputWin.c            219)   HANDLE hDev;
BlinkenOutputWin.c            220)   int err;
BlinkenOutputWin.c            221) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 222)   // open device
BlinkenLib/BlinkenOutputWin.c 223)   hDev =
BlinkenLib/BlinkenOutputWin.c 224)       CreateFile(device, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING,
BlinkenLib/BlinkenOutputWin.c 225)                  0, NULL);
BlinkenLib/BlinkenOutputWin.c 226)   if (hDev == INVALID_HANDLE_VALUE) {
BlinkenLib/BlinkenOutputWin.c 227)     if (*p_device_output_active)
BlinkenLib/BlinkenOutputWin.c 228)       printf("could not open \"%s\": error %u\n", device, GetLastError());
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            229)     return 0;
BlinkenOutputWin.c            230)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 231)   // setup serial port
BlinkenLib/BlinkenOutputWin.c 232)   if (serial_settings_change) {
BlinkenLib/BlinkenOutputWin.c 233)     if (!serial_settings_set(hDev, serial_settings)) {
BlinkenLib/BlinkenOutputWin.c 234)       if (*p_device_output_active)
BlinkenLib/BlinkenOutputWin.c 235)         printf("could not set serial port to \"%s\"\n", serial_settings);
BlinkenLib/BlinkenOutputWin.c 236)       CloseHandle(hDev);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            237)       return 0;
BlinkenOutputWin.c            238)     }
BlinkenOutputWin.c            239)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 240)   // receive frames and output to device
BlinkenLib/BlinkenOutputWin.c 241)   err = recv_and_out(udpSocket, hDev, p_device_output_active,
BlinkenLib/BlinkenOutputWin.c 242)                      format_change, format_height, format_width,
BlinkenLib/BlinkenOutputWin.c 243)                      format_channels, format_colors, proto, 0, 0,
BlinkenLib/BlinkenOutputWin.c 244)                      serial_settings_change);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            245) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 246)   // close device
BlinkenLib/BlinkenOutputWin.c 247)   CloseHandle(hDev);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            248) 
BlinkenOutputWin.c            249)   return err;
BlinkenOutputWin.c            250) }
BlinkenOutputWin.c            251) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 252) // open device and output frames in a loop
BlinkenLib/BlinkenOutputWin.c 253) // returns error code (not for device-errors, 0 for success)
BlinkenLib/BlinkenOutputWin.c 254) static int open_and_output_loop(SOCKET udpSocket, char *device,
BlinkenLib/BlinkenOutputWin.c 255)                                 int serial_settings_change,
BlinkenLib/BlinkenOutputWin.c 256)                                 char *serial_settings, int reopen_device,
BlinkenLib/BlinkenOutputWin.c 257)                                 unsigned int reopen_device_ms,
BlinkenLib/BlinkenOutputWin.c 258)                                 unsigned int format_change,
BlinkenLib/BlinkenOutputWin.c 259)                                 unsigned int format_height,
BlinkenLib/BlinkenOutputWin.c 260)                                 unsigned int format_width,
BlinkenLib/BlinkenOutputWin.c 261)                                 unsigned int format_channels,
BlinkenLib/BlinkenOutputWin.c 262)                                 unsigned int format_colors,
BlinkenLib/BlinkenOutputWin.c 263)                                 etBlinkenProto proto)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            264) {
BlinkenOutputWin.c            265)   int device_output_active, err;
BlinkenOutputWin.c            266) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 267)   printf("receiving frames and outputting them to \"%s\"...\n", device);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            268)   device_output_active = 1;
BlinkenOutputWin.c            269) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 270)   for (;;) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            271) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 272)     // try to open device and output frames
BlinkenLib/BlinkenOutputWin.c 273)     err = open_and_output(udpSocket, device,
BlinkenLib/BlinkenOutputWin.c 274)                           &device_output_active,
BlinkenLib/BlinkenOutputWin.c 275)                           serial_settings_change, serial_settings,
BlinkenLib/BlinkenOutputWin.c 276)                           format_change, format_height, format_width,
BlinkenLib/BlinkenOutputWin.c 277)                           format_channels, format_colors, proto);
BlinkenLib/BlinkenOutputWin.c 278)     if (err != 0 || !reopen_device)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            279)       break;
BlinkenOutputWin.c            280) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 281)     // output to device stopped
BlinkenLib/BlinkenOutputWin.c 282)     if (device_output_active)
BlinkenLib/BlinkenOutputWin.c 283)       printf("output to device stopped...\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            284)     device_output_active = 0;
BlinkenOutputWin.c            285) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 286)     // only fetch data from socket for a short time
BlinkenLib/BlinkenOutputWin.c 287)     err = recv_and_out(udpSocket, INVALID_HANDLE_VALUE, &device_output_active,
BlinkenLib/BlinkenOutputWin.c 288)                        format_change, format_height, format_width,
BlinkenLib/BlinkenOutputWin.c 289)                        format_channels, format_colors, proto, 1,
BlinkenLib/BlinkenOutputWin.c 290)                        reopen_device_ms, serial_settings_change);
BlinkenLib/BlinkenOutputWin.c 291)     if (err != 0)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            292)       break;
BlinkenOutputWin.c            293) 
BlinkenOutputWin.c            294)   }
BlinkenOutputWin.c            295) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 296)   // output to device finshed
BlinkenLib/BlinkenOutputWin.c 297)   if (device_output_active)
BlinkenLib/BlinkenOutputWin.c 298)     printf("output to device finished...\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            299)   device_output_active = 0;
BlinkenOutputWin.c            300) 
BlinkenOutputWin.c            301)   return err;
BlinkenOutputWin.c            302) }
BlinkenOutputWin.c            303) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 304) int main(int argCnt, char **args)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            305) {
BlinkenOutputWin.c            306)   WSADATA WsaData;
BlinkenOutputWin.c            307)   int i, bound;
BlinkenOutputWin.c            308)   SOCKET udpSocket;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 309)   char *serial_settings;
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            310)   etBlinkenProto proto;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 311)   unsigned int format_change, format_height, format_width, format_channels,
BlinkenLib/BlinkenOutputWin.c 312)       format_colors;
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            313)   unsigned int height, width, channels, colors, reopen_device_ms;
BlinkenOutputWin.c            314)   int serial_settings_change, reopen_device, unblock;
BlinkenOutputWin.c            315)   char txt[64];
BlinkenOutputWin.c            316)   unsigned short port;
BlinkenOutputWin.c            317)   struct sockaddr_in addr;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 318)   char *device;
BlinkenLib/BlinkenOutputWin.c 319) 
BlinkenLib/BlinkenOutputWin.c 320)   // print info
BlinkenLib/BlinkenOutputWin.c 321)   printf("BlinkenLib - BlinkenOutput\n"
Stefan Schuermans update email address of author

Stefan Schuermans authored 10 years ago

BlinkenLib/BlinkenOutputWin.c 322)          "Copyright 2004-2014 Stefan Schuermans <stefan@schuermans.info>\n"
Stefan Schuermans cleanup file headers after...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 323)          "Copyleft GNU public license - http://www.gnu.org/copyleft/gpl.html\n"
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 324)          "a blinkenarea.org project\n\n");
BlinkenLib/BlinkenOutputWin.c 325) 
BlinkenLib/BlinkenOutputWin.c 326)   // print syntax
BlinkenLib/BlinkenOutputWin.c 327)   if (argCnt <= 1) {
BlinkenLib/BlinkenOutputWin.c 328)     printf("syntax: %s <parameter> [...]\n\n"
BlinkenLib/BlinkenOutputWin.c 329)            "parameters:\n"
BlinkenLib/BlinkenOutputWin.c 330)            "  -l [<ip>:]<port>\n"
BlinkenLib/BlinkenOutputWin.c 331)            "     local address (defaults to 0.0.0.0:2323)\n"
BlinkenLib/BlinkenOutputWin.c 332)            "     must occur before -r, may only occur once\n"
BlinkenLib/BlinkenOutputWin.c 333)            "  -r <ip>[:<port>]\n"
BlinkenLib/BlinkenOutputWin.c 334)            "     remote addess (defaults to every remote address)\n"
BlinkenLib/BlinkenOutputWin.c 335)            "  -p [BLP|EBLP|MCUF]\n"
BlinkenLib/BlinkenOutputWin.c 336)            "     protocol to output frames in (defaults to MCUF)\n"
BlinkenLib/BlinkenOutputWin.c 337)            "  -f <width>x<height>-<channels>/<colors>\n"
BlinkenLib/BlinkenOutputWin.c 338)            "     format to output frames in (defaults to no change)\n"
BlinkenLib/BlinkenOutputWin.c 339)            "  -d <device>\n"
BlinkenLib/BlinkenOutputWin.c 340)            "     device to output frames to (defaults to \"NUL\")\n"
BlinkenLib/BlinkenOutputWin.c 341)            "  -s <baud-rate>,<parity>,<data-bits>,<stop-bits>\n"
BlinkenLib/BlinkenOutputWin.c 342)            "     settings to use for serial devices (defaults to no change)\n"
BlinkenLib/BlinkenOutputWin.c 343)            "  -o <milliseconds>\n"
BlinkenLib/BlinkenOutputWin.c 344)            "     reopen device after short time on error (defaults to not reopen)\n"
BlinkenLib/BlinkenOutputWin.c 345)            "\n", args[0]);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            346)     return 0;
BlinkenOutputWin.c            347)   }
BlinkenOutputWin.c            348) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 349)   WSAStartup(0x0101, &WsaData);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            350) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 351)   // create udp socket
BlinkenLib/BlinkenOutputWin.c 352)   udpSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
BlinkenLib/BlinkenOutputWin.c 353)   if (udpSocket == INVALID_SOCKET) {
BlinkenLib/BlinkenOutputWin.c 354)     printf("cannot create UDP socket: error %lu\n", WSAGetLastError());
BlinkenLib/BlinkenOutputWin.c 355)     WSACleanup();
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            356)     return -1;
BlinkenOutputWin.c            357)   }
BlinkenOutputWin.c            358)   bound = 0;
BlinkenOutputWin.c            359) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 360)   // unblock udp socket
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            361)   unblock = 1;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 362)   if (ioctlsocket(udpSocket, FIONBIO, &unblock) == SOCKET_ERROR) {
BlinkenLib/BlinkenOutputWin.c 363)     printf("cannot unblock UDP socket: error %lu\n", WSAGetLastError());
BlinkenLib/BlinkenOutputWin.c 364)     closesocket(udpSocket);
BlinkenLib/BlinkenOutputWin.c 365)     WSACleanup();
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            366)     return -1;
BlinkenOutputWin.c            367)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 368)   // process parameters
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            369)   proto = BlinkenProtoMcuf;
BlinkenOutputWin.c            370)   format_change = 0;
BlinkenOutputWin.c            371)   format_height = 0;
BlinkenOutputWin.c            372)   format_width = 0;
BlinkenOutputWin.c            373)   format_channels = 0;
BlinkenOutputWin.c            374)   format_colors = 0;
BlinkenOutputWin.c            375)   device = "NUL";
BlinkenOutputWin.c            376)   serial_settings_change = 0;
BlinkenOutputWin.c            377)   reopen_device = 0;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 378)   for (i = 1; i < argCnt; i++) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            379) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 380)     // local address
BlinkenLib/BlinkenOutputWin.c 381)     if (strcmp(args[i], "-l") == 0) {
BlinkenLib/BlinkenOutputWin.c 382)       if (i + 1 < argCnt) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            383)         i++;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 384)         if (sscanf(args[i], "%32[0-9.]:%hu", txt, &port) == 2) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            385)           addr.sin_family = AF_INET;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 386)           addr.sin_port = htons(port);
BlinkenLib/BlinkenOutputWin.c 387)           addr.sin_addr.s_addr = inet_addr(txt);
BlinkenLib/BlinkenOutputWin.c 388)           if (bind(udpSocket, (struct sockaddr *)&addr, sizeof(addr)) != 0)
BlinkenLib/BlinkenOutputWin.c 389)             printf("could not set local address to \"%s\"\n", args[i]);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            390)           else
BlinkenOutputWin.c            391)             bound = 1;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 392)         } else if (sscanf(args[i], "%hu", &port) == 1) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            393)           addr.sin_family = AF_INET;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 394)           addr.sin_port = htons(port);
BlinkenLib/BlinkenOutputWin.c 395)           addr.sin_addr.s_addr = htonl(INADDR_ANY);
BlinkenLib/BlinkenOutputWin.c 396)           if (bind(udpSocket, (struct sockaddr *)&addr, sizeof(addr)) != 0)
BlinkenLib/BlinkenOutputWin.c 397)             printf("could not set local address to \"%s\"\n", args[i]);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            398)           else
BlinkenOutputWin.c            399)             bound = 1;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 400)         } else
BlinkenLib/BlinkenOutputWin.c 401)           printf("invalid local address \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 402)       } else
BlinkenLib/BlinkenOutputWin.c 403)         printf("missing local address for \"-l\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            404)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 405)     // remote address
BlinkenLib/BlinkenOutputWin.c 406)     else if (strcmp(args[i], "-r") == 0) {
BlinkenLib/BlinkenOutputWin.c 407)       if (i + 1 < argCnt) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            408)         i++;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 409)         if (sscanf(args[i], "%32[0-9.]:%hu", txt, &port) == 2) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            410)           addr.sin_family = AF_INET;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 411)           addr.sin_port = htons(port);
BlinkenLib/BlinkenOutputWin.c 412)           addr.sin_addr.s_addr = inet_addr(txt);
BlinkenLib/BlinkenOutputWin.c 413)           if (connect(udpSocket, (struct sockaddr *)&addr, sizeof(addr)) != 0)
BlinkenLib/BlinkenOutputWin.c 414)             printf("could not set remote address to \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 415)         } else if (sscanf(args[i], "%32[0-9.]", txt) == 1) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            416)           addr.sin_family = AF_INET;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 417)           addr.sin_port = htons(23230);
BlinkenLib/BlinkenOutputWin.c 418)           addr.sin_addr.s_addr = inet_addr(txt);
BlinkenLib/BlinkenOutputWin.c 419)           if (connect(udpSocket, (struct sockaddr *)&addr, sizeof(addr)) != 0)
BlinkenLib/BlinkenOutputWin.c 420)             printf("could not set remote address to \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 421)         } else
BlinkenLib/BlinkenOutputWin.c 422)           printf("invalid remote address \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 423)       } else
BlinkenLib/BlinkenOutputWin.c 424)         printf("missing remote address for \"-r\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            425)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 426)     // protocol to output frames in
BlinkenLib/BlinkenOutputWin.c 427)     else if (strcmp(args[i], "-p") == 0) {
BlinkenLib/BlinkenOutputWin.c 428)       if (i + 1 < argCnt) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            429)         i++;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 430)         if (stricmp(args[i], "BLP") == 0)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            431)           proto = BlinkenProtoBlp;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 432)         else if (stricmp(args[i], "EBLP") == 0)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            433)           proto = BlinkenProtoEblp;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 434)         else if (stricmp(args[i], "MCUF") == 0)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            435)           proto = BlinkenProtoMcuf;
BlinkenOutputWin.c            436)         else
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 437)           printf("unknown protocol \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 438)       } else
BlinkenLib/BlinkenOutputWin.c 439)         printf("missing protocol for \"-p\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            440)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 441)     // format to output frames in
BlinkenLib/BlinkenOutputWin.c 442)     else if (strcmp(args[i], "-f") == 0) {
BlinkenLib/BlinkenOutputWin.c 443)       if (i + 1 < argCnt) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            444)         i++;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 445)         if (sscanf
BlinkenLib/BlinkenOutputWin.c 446)             (args[i], "%ux%u-%u/%u", &width, &height, &channels, &colors) == 4
BlinkenLib/BlinkenOutputWin.c 447)             && width > 0 && width < 1000 && height > 0 && height < 1000
BlinkenLib/BlinkenOutputWin.c 448)             && channels > 0 && channels < 20 && colors > 1 && colors <= 256) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            449)           format_change = 1;
BlinkenOutputWin.c            450)           format_height = height;
BlinkenOutputWin.c            451)           format_width = width;
BlinkenOutputWin.c            452)           format_channels = channels;
BlinkenOutputWin.c            453)           format_colors = colors;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 454)         } else
BlinkenLib/BlinkenOutputWin.c 455)           printf("invalid frame format \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 456)       } else
BlinkenLib/BlinkenOutputWin.c 457)         printf("missing frame format for \"-r\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            458)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 459)     // device to output frames to
BlinkenLib/BlinkenOutputWin.c 460)     else if (strcmp(args[i], "-d") == 0) {
BlinkenLib/BlinkenOutputWin.c 461)       if (i + 1 < argCnt) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            462)         i++;
BlinkenOutputWin.c            463)         device = args[i];
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 464)       } else
BlinkenLib/BlinkenOutputWin.c 465)         printf("missing device name for \"-d\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            466)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 467)     // settings for serial output devices
BlinkenLib/BlinkenOutputWin.c 468)     else if (strcmp(args[i], "-s") == 0) {
BlinkenLib/BlinkenOutputWin.c 469)       if (i + 1 < argCnt) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            470)         i++;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 471)         if (serial_settings_parse(args[i])) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            472)           serial_settings_change = 1;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 473)           serial_settings = args[i];
BlinkenLib/BlinkenOutputWin.c 474)         } else
BlinkenLib/BlinkenOutputWin.c 475)           printf("invalid serial settings \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 476)       } else
BlinkenLib/BlinkenOutputWin.c 477)         printf("missing serial settings for \"-s\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            478)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 479)     // reopen device on error after some time
BlinkenLib/BlinkenOutputWin.c 480)     else if (strcmp(args[i], "-o") == 0) {
BlinkenLib/BlinkenOutputWin.c 481)       if (i + 1 < argCnt) {
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            482)         i++;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 483)         if (sscanf(args[i], "%u", &reopen_device_ms) == 1
BlinkenLib/BlinkenOutputWin.c 484)             && reopen_device_ms >= 1)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            485)           reopen_device = 1;
BlinkenOutputWin.c            486)         else
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 487)           printf("invalid number of milliseconds \"%s\"\n", args[i]);
BlinkenLib/BlinkenOutputWin.c 488)       } else
BlinkenLib/BlinkenOutputWin.c 489)         printf("missing time for \"-o\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            490)     }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 491)     // unknown parameter
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            492)     else
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 493)       printf
BlinkenLib/BlinkenOutputWin.c 494)           ("unknown parameter \"%s\", call without parameters to get help\n",
BlinkenLib/BlinkenOutputWin.c 495)            args[i]);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            496) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 497)   }     // for( i ...
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            498) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 499)   // try to bind if not bound
BlinkenLib/BlinkenOutputWin.c 500)   if (!bound) {
BlinkenLib/BlinkenOutputWin.c 501)     printf("no local address to receive frames on,\n"
BlinkenLib/BlinkenOutputWin.c 502)            "  using default local address \"0.0.0.0:2323\"\n");
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            503)     addr.sin_family = AF_INET;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 504)     addr.sin_port = htons(2323);
BlinkenLib/BlinkenOutputWin.c 505)     addr.sin_addr.s_addr = htonl(INADDR_ANY);
BlinkenLib/BlinkenOutputWin.c 506)     if (bind(udpSocket, (struct sockaddr *)&addr, sizeof(addr)) == 0)
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            507)       bound = 1;
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 508)     else {
BlinkenLib/BlinkenOutputWin.c 509)       printf("could not set local address to \"0.0.0.0:2323\"\n");
BlinkenLib/BlinkenOutputWin.c 510)       closesocket(udpSocket);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            511)       return -1;
BlinkenOutputWin.c            512)     }
BlinkenOutputWin.c            513)   }
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 514)   // open device and output frames in a loop
BlinkenLib/BlinkenOutputWin.c 515)   open_and_output_loop(udpSocket, device,
BlinkenLib/BlinkenOutputWin.c 516)                        serial_settings_change, serial_settings,
BlinkenLib/BlinkenOutputWin.c 517)                        reopen_device, reopen_device_ms,
BlinkenLib/BlinkenOutputWin.c 518)                        format_change, format_height, format_width,
BlinkenLib/BlinkenOutputWin.c 519)                        format_channels, format_colors, proto);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            520) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 521)   // close socket
BlinkenLib/BlinkenOutputWin.c 522)   closesocket(udpSocket);
Christian Heimke BlinkenLib v.0.5.2 (2006-05...

Christian Heimke authored 13 years ago

BlinkenOutputWin.c            523) 
Stefan Schuermans changed indenting to be mor...

Stefan Schuermans authored 13 years ago

BlinkenLib/BlinkenOutputWin.c 524)   WSACleanup();