Changeset 7917 for trunk/Ohana/src/opihi/dimm/Serial.c
- Timestamp:
- Jul 16, 2006, 10:58:49 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/dimm/Serial.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/dimm/Serial.c
r2598 r7917 53 53 serial.f = SerialOpen (serial.port); 54 54 if (serial.f <= 0) { 55 fprintf (stderr, "Error opening serial port %s - error %d.\n", serial.port, serial.f);55 gprint (GP_ERR, "Error opening serial port %s - error %d.\n", serial.port, serial.f); 56 56 return (FALSE); 57 57 } … … 77 77 fdesc = open (port, O_RDWR); 78 78 if (fdesc == -1) { 79 if (SER_VERBOSE) fprintf(stderr, "Cannot open %s for read/write.\n", port);79 if (SER_VERBOSE) gprint (GP_ERR, "Cannot open %s for read/write.\n", port); 80 80 return OPENERR; 81 81 } … … 87 87 locked = fcntl (fdesc, F_SETLK, &lock); 88 88 if (locked == -1) { 89 fprintf (stderr, "can't lock serial line\n");89 gprint (GP_ERR, "can't lock serial line\n"); 90 90 close (fdesc); 91 91 return OPENERR; … … 94 94 /* Get the serial port's attributes... */ 95 95 if (tcgetattr (fdesc, &term) == -1) { 96 if (SER_VERBOSE) fprintf(stderr, "Port is not a tty\n");96 if (SER_VERBOSE) gprint (GP_ERR, "Port is not a tty\n"); 97 97 return PORTERR; 98 98 } … … 133 133 if (SER_VERBOSE) printf("Setting the serial port's baud rate.\n"); 134 134 if (tcgetattr (fdesc, &term) == -1) { 135 if (SER_VERBOSE) fprintf (stderr, "Port is not a tty\n");135 if (SER_VERBOSE) gprint (GP_ERR, "Port is not a tty\n"); 136 136 return PORTERR; 137 137 } … … 174 174 if (SER_VERBOSE) printf("Setting the serial port's parity.\n"); 175 175 if (tcgetattr(fdesc, &term) == -1) { 176 if (SER_VERBOSE) fprintf(stderr, "Port is not a tty\n");176 if (SER_VERBOSE) gprint (GP_ERR, "Port is not a tty\n"); 177 177 return PORTERR; 178 178 } … … 202 202 if (SER_VERBOSE) printf("Setting the serial port's data bit size.\n"); 203 203 if (tcgetattr(fdesc, &term) == -1) { 204 if (SER_VERBOSE) fprintf(stderr, "Port is not a tty\n");204 if (SER_VERBOSE) gprint (GP_ERR, "Port is not a tty\n"); 205 205 return PORTERR; 206 206 } … … 241 241 if (SER_VERBOSE) printf("Setting the serial port's stop bit.\n"); 242 242 if (tcgetattr(fdesc, &term) == -1) { 243 if (SER_VERBOSE) fprintf(stderr, "Port is not a tty\n");243 if (SER_VERBOSE) gprint (GP_ERR, "Port is not a tty\n"); 244 244 return PORTERR; 245 245 } … … 274 274 int done, Nread, Nin, NREAD; 275 275 276 if (SER_ECHO) fprintf (stderr, "command: %s\n", in);276 if (SER_ECHO) gprint (GP_ERR, "command: %s\n", in); 277 277 278 278 if (serial.f <= 0) { 279 fprintf (stderr, "serial line closed\n");279 gprint (GP_ERR, "serial line closed\n"); 280 280 if (out != (char **) NULL) { 281 281 *out = strcreate ("SERIAL OFF"); … … 290 290 # if (0) 291 291 for (i = 0; i < strlen(in); i++) { 292 fprintf (stderr, "%d %x\n", i, in[i]);292 gprint (GP_ERR, "%d %x\n", i, in[i]); 293 293 } 294 294 # endif … … 297 297 Nin = write (serial.f, in, strlen(in)); 298 298 if (Nin != strlen(in)) { 299 fprintf (stderr, "Serial Command not sent\n");299 gprint (GP_ERR, "Serial Command not sent\n"); 300 300 return (FALSE); 301 301 } … … 316 316 Nin = read (serial.f, &line[Nread], 256); 317 317 # if (SER_DEBUG) 318 fprintf (stderr, "%d ", Nin);318 gprint (GP_ERR, "%d ", Nin); 319 319 # endif 320 320 if (Nin < 0) { /* error, check value */ 321 fprintf (stderr, "error?");321 gprint (GP_ERR, "error?"); 322 322 continue; 323 323 } … … 335 335 } 336 336 337 if (SER_ECHO) fprintf (stderr, "answer: %s\n", line);337 if (SER_ECHO) gprint (GP_ERR, "answer: %s\n", line); 338 338 339 339 if (out == (char **) NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.
