little changes: arg reordering, ...

This commit is contained in:
marschap
2005-05-31 14:53:18 +00:00
parent b4d557123c
commit ea214762ef
4 changed files with 42 additions and 41 deletions
+8 -7
View File
@@ -291,6 +291,7 @@ CFontz633_init (Driver *drvthis, char *args)
CFontz633_reboot (drvthis);
reboot = 0;
}
CFontz633_hidecursor (drvthis);
CFontz633_set_contrast (drvthis, p->contrast);
@@ -370,7 +371,7 @@ CFontz633_flush (Driver *drvthis)
out[0] = (unsigned char) (i % p->width); // column
out[1] = (unsigned char) (i / p->width); // line
out[2] = p->framebuf[i]; // character
send_bytes_message(fd, 3, CF633_Send_Data_to_LCD, out);
send_bytes_message(fd, CF633_Send_Data_to_LCD, 3, out);
p->backingstore[i] = p->framebuf[i];
}
}
@@ -384,7 +385,7 @@ CFontz633_flush (Driver *drvthis)
for (i = 0; i < p->width; i++) {
if (*xp++ != *xq++) {
send_bytes_message(p->fd, 16, CF633_Set_LCD_Contents_Line_One, p->framebuf);
send_bytes_message(p->fd, CF633_Set_LCD_Contents_Line_One, 16, p->framebuf);
memcpy(p->backingstore, p->framebuf, p->width);
break;
}
@@ -395,7 +396,7 @@ CFontz633_flush (Driver *drvthis)
for (i = 0; i < p->width; i++) {
if (*xp++ != *xq++) {
send_bytes_message(p->fd, 16, CF633_Set_LCD_Contents_Line_Two, p->framebuf + p->width);
send_bytes_message(p->fd, CF633_Set_LCD_Contents_Line_Two, 16, p->framebuf + p->width);
memcpy(p->backingstore + p->width, p->framebuf + p->width, p->width);
break;
}
@@ -536,7 +537,7 @@ CFontz633_no_live_report (Driver *drvthis)
unsigned char out[2] = { 0, 0 };
for (out[0] = 0; out[0] < 8; out[0]++) {
send_bytes_message(p->fd, 2, CF633_Set_Up_Live_Fan_or_Temperature_Display, out);
send_bytes_message(p->fd, CF633_Set_Up_Live_Fan_or_Temperature_Display, 2, out);
}
}
@@ -562,7 +563,7 @@ CFontz633_no_temp_report (Driver *drvthis)
PrivateData *p = drvthis->private_data;
unsigned char out[4] = { 0, 0, 0, 0 };
send_bytes_message(p->fd, 4, CF633_Set_Up_Temperature_Reporting, out);
send_bytes_message(p->fd, CF633_Set_Up_Temperature_Reporting, 4, out);
}
@@ -575,7 +576,7 @@ CFontz633_reboot (Driver *drvthis)
PrivateData *p = drvthis->private_data;
unsigned char out[3] = { 8, 18, 99 };
send_bytes_message(p->fd, 3, CF633_Reboot, out);
send_bytes_message(p->fd, CF633_Reboot, 3, out);
sleep(2);
}
@@ -848,7 +849,7 @@ CFontz633_set_char (Driver *drvthis, int n, char *dat)
}
out[row+1] = letter;
}
send_bytes_message(p->fd, 9, CF633_Set_LCD_Special_Character_Data, out);
send_bytes_message(p->fd, CF633_Set_LCD_Special_Character_Data, 9, out);
}
+14 -11
View File
@@ -14,6 +14,7 @@
* www.crystalfontz.com
* ===========================================================================
*/
#include "CFontz633io.h"
#include <unistd.h>
#include <stdio.h>
@@ -25,11 +26,12 @@
#define GIVE_UP 2
/* static local fuinctions */
/* static local functions */
static void send_packet(int fd, COMMAND_PACKET *out);
static int get_crc(char * bufptr, int len, int seed);
static int check_for_packet(int fd, unsigned char expected_length);
static int get_crc(char *buf, int len, int seed);
static int test_packet(int fd);
static void treat_packet(void);
static int check_for_packet(int fd, unsigned char expected_length);
static void print_packet(COMMAND_PACKET *packet);
@@ -91,13 +93,13 @@ unsigned char GetKeyFromKeyRing(KeyRing *kr)
/** send message with arguments to the given handle */
void send_bytes_message(int fd, int len, int msg, unsigned char *data)
void send_bytes_message(int fd, unsigned char msg, int len, unsigned char *data)
{
COMMAND_PACKET out;
out.command = msg;
out.data_length = len;
memcpy(out.data, data, len);
out.data_length = (unsigned char) ((len > MAX_DATA_LENGTH) ? MAX_DATA_LENGTH : len);
memcpy(out.data, data, out.data_length);
/* send message & calc CRC */
send_packet(fd, &out);
@@ -105,7 +107,7 @@ void send_bytes_message(int fd, int len, int msg, unsigned char *data)
/** send message with one byte argument to the given handle */
void send_onebyte_message(int fd, int msg, unsigned char value)
void send_onebyte_message(int fd, unsigned char msg, unsigned char value)
{
COMMAND_PACKET out;
@@ -119,7 +121,7 @@ void send_onebyte_message(int fd, int msg, unsigned char value)
/** send message without data to the given handle */
void send_zerobyte_message(int fd, int msg)
void send_zerobyte_message(int fd, unsigned char msg)
{
COMMAND_PACKET out;
@@ -237,7 +239,7 @@ void EmptyReceiveBuffer(ReceiveBuffer *rb)
/** read given number of bytes from given file handle into receive buffer */
void SyncReceiveBuffer(int fd, ReceiveBuffer *rb, unsigned int number)
void SyncReceiveBuffer(ReceiveBuffer *rb, int fd, unsigned int number)
{
unsigned char buffer[MAX_DATA_LENGTH];
int BytesRead;
@@ -354,7 +356,8 @@ unsigned char PeekByte(ReceiveBuffer *rb)
/* I should use the value GIVE_UP and not reenter if there is no extra
* byte read from the serial port
*/
int test_packet(int fd)
static int
test_packet(int fd)
{
int is_msg;
@@ -403,7 +406,7 @@ check_for_packet(int fd, unsigned char expected_length)
int i;
int testcrc;
SyncReceiveBuffer(fd, &receivebuffer, expected_length);
SyncReceiveBuffer(&receivebuffer, fd, expected_length);
//First off, there must be at least 4 bytes available in the input stream
//for there to be a valid command in it (command, length, no data, CRC).
+13 -16
View File
@@ -81,7 +81,7 @@ typedef struct _reveivebuffer {
int head;
int tail;
int peek;
} ReceiveBuffer;
} ReceiveBuffer;
/* command management */
@@ -89,36 +89,33 @@ typedef struct _reveivebuffer {
#define MAX_COMMAND 32
typedef struct {
ubyte command;
ubyte data_length;
ubyte data[MAX_DATA_LENGTH+1];
union {
unsigned char as_bytes[2];
word as_word;
} crc;
ubyte command;
ubyte data_length;
ubyte data[MAX_DATA_LENGTH+1];
union {
unsigned char as_bytes[2];
word as_word;
} crc;
} COMMAND_PACKET;
/* KeyRing management */
void EmptyKeyRing(KeyRing *kr);
int AddKeyToKeyRing(KeyRing *kr, unsigned char key);
unsigned char GetKeyFromKeyRing(KeyRing *kr);
void send_bytes_message(int fd, int len, int msg, unsigned char *data);
void send_onebyte_message(int fd, int msg, unsigned char value);
void send_zerobyte_message(int fd, int msg);
void send_bytes_message(int fd, unsigned char msg, int len, unsigned char *data);
void send_onebyte_message(int fd, unsigned char msg, unsigned char value);
void send_zerobyte_message(int fd, unsigned char msg);
void EmptyReceiveBuffer(ReceiveBuffer *rb);
void SyncReceiveBuffer(int fd, ReceiveBuffer *rb, unsigned int number);
int BytesAvail(ReceiveBuffer *rb);
void SyncReceiveBuffer(ReceiveBuffer *rb, int fd, unsigned int number);
int BytesAvail(ReceiveBuffer *rb);
unsigned char GetByte(ReceiveBuffer *rb);
int PeekBytesAvail(ReceiveBuffer *rb);
void SyncPeekPointer(ReceiveBuffer *rb);
void AcceptPeekedData(ReceiveBuffer *rb);
unsigned char PeekByte(ReceiveBuffer *rb);
int test_packet(int fd);
/* global variables */
extern KeyRing keyring;
+7 -7
View File
@@ -434,7 +434,7 @@ CFontz633_flush (Driver *drvthis)
for (i = 0; i < p->width; i++) {
if (*xp++ != *xq++) {
send_bytes_message(p->fd, 16, CF633_Set_LCD_Contents_Line_One, p->framebuf);
send_bytes_message(p->fd, CF633_Set_LCD_Contents_Line_One, 16, p->framebuf);
memcpy(p->backingstore, p->framebuf, p->width);
break;
}
@@ -445,7 +445,7 @@ CFontz633_flush (Driver *drvthis)
for (i = 0; i < p->width; i++) {
if (*xp++ != *xq++) {
send_bytes_message(p->fd, 16, CF633_Set_LCD_Contents_Line_Two, p->framebuf + p->width);
send_bytes_message(p->fd, CF633_Set_LCD_Contents_Line_Two, 16, p->framebuf + p->width);
memcpy(p->backingstore + p->width, p->framebuf + p->width, p->width);
break;
}
@@ -489,7 +489,7 @@ CFontz633_flush (Driver *drvthis)
&p->framebuf[first_diff + (i * p->width)] );
memcpy(&out[2], &p->framebuf[first_diff + (i * p->width)], diff_length );
send_bytes_message(p->fd, diff_length + 2, CF633_Send_Data_to_LCD, out);
send_bytes_message(p->fd, CF633_Send_Data_to_LCD, diff_length + 2, out);
}
} // j < p->width
} // i < p->height
@@ -659,7 +659,7 @@ CFontz633_no_live_report (Driver *drvthis)
if (p->model == 633) {
for (out[0] = 0; out[0] < 8; out[0]++)
send_bytes_message(p->fd, 2, CF633_Set_Up_Live_Fan_or_Temperature_Display, out);
send_bytes_message(p->fd, CF633_Set_Up_Live_Fan_or_Temperature_Display, 2, out);
}
}
@@ -687,7 +687,7 @@ CFontz633_no_temp_report (Driver *drvthis)
unsigned char out[4] = { 0, 0, 0, 0 };
if (p->model == 633)
send_bytes_message(p->fd, 4, CF633_Set_Up_Temperature_Reporting, out);
send_bytes_message(p->fd, CF633_Set_Up_Temperature_Reporting, 4, out);
}
@@ -700,7 +700,7 @@ CFontz633_reboot (Driver *drvthis)
PrivateData *p = drvthis->private_data;
unsigned char out[3] = { 8, 18, 99 };
send_bytes_message(p->fd, 3, CF633_Reboot, out);
send_bytes_message(p->fd, CF633_Reboot, 3, out);
sleep(2);
}
@@ -973,7 +973,7 @@ CFontz633_set_char (Driver *drvthis, int n, char *dat)
}
out[row+1] = letter;
}
send_bytes_message(p->fd, 9, CF633_Set_LCD_Special_Character_Data, out);
send_bytes_message(p->fd, CF633_Set_LCD_Special_Character_Data, 9, out);
}