space cleanup

This commit is contained in:
marschap
2005-05-26 17:41:54 +00:00
parent 8296d0b716
commit 3658cedc35
+9 -10
View File
@@ -200,7 +200,7 @@ send_packet(int fd)
for (i = 0; i < outgoing_response.data_length; i++) { for (i = 0; i < outgoing_response.data_length; i++) {
SendByte(fd, outgoing_response.data[i]); SendByte(fd, outgoing_response.data[i]);
} }
/* calculate & send the CRC */ /* calculate & send the CRC */
outgoing_response.CRC.as_word = get_crc((unsigned char *) &outgoing_response, outgoing_response.CRC.as_word = get_crc((unsigned char *) &outgoing_response,
outgoing_response.data_length + 2, 0xFFFF); outgoing_response.data_length + 2, 0xFFFF);
@@ -251,10 +251,10 @@ void Sync_Read_Buffer(int fd, unsigned char expected_bytes)
{ {
unsigned char Incoming[512]; unsigned char Incoming[512];
int BytesRead; int BytesRead;
// ToDo: check that expected_bytes < sizeof(Incoming) // ToDo: check that expected_bytes < sizeof(Incoming)
BytesRead = read(fd, Incoming, expected_bytes); BytesRead = read(fd, Incoming, expected_bytes);
if (BytesRead == -1){ if (BytesRead == -1) {
/* printf("~~~Problem reading: %s .\n", strerror(errno)); */ /* printf("~~~Problem reading: %s .\n", strerror(errno)); */
} }
else { else {
@@ -271,7 +271,7 @@ void Sync_Read_Buffer(int fd, unsigned char expected_bytes)
SerialReceiveBuffer[ReceiveBufferHead] = Incoming[i]; SerialReceiveBuffer[ReceiveBufferHead] = Incoming[i];
/* increment write pointer (wrap if needed) */ /* increment write pointer (wrap if needed) */
ReceiveBufferHead = (ReceiveBufferHead + 1) % RECEIVEBUFFERSIZE; ReceiveBufferHead = (ReceiveBufferHead + 1) % RECEIVEBUFFERSIZE;
} }
/* printf("\n"); */ /* printf("\n"); */
} }
@@ -282,7 +282,7 @@ void Sync_Read_Buffer(int fd, unsigned char expected_bytes)
int BytesAvail(void) int BytesAvail(void)
{ {
int avail_bytes = ReceiveBufferHead - ReceiveBufferTail; int avail_bytes = ReceiveBufferHead - ReceiveBufferTail;
if (avail_bytes < 0) if (avail_bytes < 0)
avail_bytes += RECEIVEBUFFERSIZE; avail_bytes += RECEIVEBUFFERSIZE;
@@ -305,7 +305,7 @@ unsigned char GetByte(void)
/* Increment read pointer (wrap if needed) */ /* Increment read pointer (wrap if needed) */
ReceiveBufferTail = (ReceiveBufferTail + 1) % RECEIVEBUFFERSIZE; ReceiveBufferTail = (ReceiveBufferTail + 1) % RECEIVEBUFFERSIZE;
} }
return(return_byte); return(return_byte);
} }
@@ -315,8 +315,7 @@ unsigned char GetByte(void)
unsigned char DiscardGetByte(void) unsigned char DiscardGetByte(void)
{ {
unsigned char return_byte = '\0'; unsigned char return_byte = '\0';
/* wrap read pointer to the receive buffer */ /* wrap read pointer to the receive buffer */
ReceiveBufferTail %= RECEIVEBUFFERSIZE; ReceiveBufferTail %= RECEIVEBUFFERSIZE;
@@ -327,7 +326,7 @@ unsigned char DiscardGetByte(void)
/* Increment read pointer (wrap if needed) */ /* Increment read pointer (wrap if needed) */
ReceiveBufferTail = (ReceiveBufferTail + 1) % RECEIVEBUFFERSIZE; ReceiveBufferTail = (ReceiveBufferTail + 1) % RECEIVEBUFFERSIZE;
} }
/* printf("Discarded : /%02x/\n", return_byte); */ /* printf("Discarded : /%02x/\n", return_byte); */
return(return_byte); return(return_byte);
@@ -375,7 +374,7 @@ unsigned char PeekByte(void)
/* Increment the peek pointer (wrap if needed). */ /* Increment the peek pointer (wrap if needed). */
ReceiveBufferTailPeek = (ReceiveBufferTailPeek + 1) % RECEIVEBUFFERSIZE; ReceiveBufferTailPeek = (ReceiveBufferTailPeek + 1) % RECEIVEBUFFERSIZE;
} }
return(return_byte); return(return_byte);
} }