Changeset 27838 for branches/tap_branches/Ohana/src/libohana/src/CommOps.c
- Timestamp:
- May 3, 2010, 8:41:49 AM (16 years ago)
- Location:
- branches/tap_branches
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/tap_branches
- Property svn:mergeinfo changed
-
branches/tap_branches/Ohana
-
Property svn:mergeinfo
set to (toggle deleted branches)
/trunk/Ohana merged eligible /branches/eam_branches/Ohana.20100407 27635-27772 /branches/pap_delete/Ohana 27530-27595
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
branches/tap_branches/Ohana/src/libohana/src/CommOps.c
r23326 r27838 14 14 return (status); 15 15 } 16 // fprintf (stderr, "resp: %s\n", command.buffer);16 // fprintf (stderr, "resp: (%d) %s\n", command.Nbuffer, command.buffer); 17 17 18 18 /* buffer contains an EOL NULL, we can just sscan it */ … … 21 21 22 22 status = ExpectCommand (device, length, timeout, message); 23 23 24 return (status); 24 25 } … … 45 46 46 47 if (Nread > 0) { 48 // fprintf (stderr, "read %d of %d\n", Nread, length - buffer[0].Nbuffer); 47 49 buffer[0].Nbuffer += Nread; 48 50 continue; … … 50 52 51 53 if (Nread == -1) { 54 // fprintf (stderr, "errno: %d\n", errno); 55 // perror ("read error"); 52 56 switch (errno) { 53 57 case EAGAIN: … … 99 103 int SendMessageFixed (int device, int length, char *message) { 100 104 105 int Nbytes, Nsent; 106 struct timespec request, remain; 107 108 // fprintf (stderr, "send fixed message, length = %d\n", length); 109 101 110 if (!SendCommand (device, 16, "NBYTES: %6d", length)) return FALSE; 102 if (!SendCommand (device, length, message)) return FALSE; 111 112 /* avoid blocking on waitpid, test every 1000 usec, up to timeout msec */ 113 request.tv_sec = 0; 114 request.tv_nsec = 1000000; 115 116 Nsent = 0; 117 while (Nsent < length) { 118 Nbytes = write (device, &message[Nsent], length - Nsent); 119 120 // fprintf (stderr, "sent %d of %d\n", Nbytes, length - Nsent); 121 122 if (Nbytes > 0) { 123 Nsent += Nbytes; 124 continue; 125 } 126 127 if (Nbytes == -1) { 128 // fprintf (stderr, "errno: %d\n", errno); 129 // perror ("send error"); 130 switch (errno) { 131 case EAGAIN: 132 case EIO: 133 /** no data available in pipe, wait a bit, check for timeout **/ 134 nanosleep (&request, &remain); 135 break; 136 default: 137 /** error reading from pipe **/ 138 perror ("SendMessageFixed write error"); 139 return FALSE; 140 } 141 } 142 if (Nbytes == 0) return FALSE; 143 } 144 // if (!SendCommand (device, length, message)) return FALSE; 145 103 146 return TRUE; 104 147 } … … 124 167 memset (string, 0, length + 1); 125 168 vsnprintf (string, length + 1, format, argp); 169 170 // fprintf (stderr, "write command, length = %d\n", length); 126 171 127 172 status = write (device, string, length);
Note:
See TracChangeset
for help on using the changeset viewer.
