summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian König <chrissi@zweiundvierzig.(none)>2010-05-30 13:06:49 +0200
committerChristian König <chrissi@zweiundvierzig.(none)>2010-05-30 13:06:49 +0200
commitcd0e30d31f8adf852a3ca579f88cc3467ef289bc (patch)
tree4b56a62a6c39d7d5cc91b0cc779ec1005f87f6a3
parent0208bfa252046a44dbb2d25a40f8d5e01057253b (diff)
Some Bugfixing
-rw-r--r--lib/Makefile2
-rw-r--r--lib/cec.h1
-rw-r--r--lib/device.c2
-rw-r--r--lib/msp430.c9
4 files changed, 9 insertions, 5 deletions
diff --git a/lib/Makefile b/lib/Makefile
index 792453e..6c5d6c8 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -2,7 +2,7 @@ NAME = libcec
OBJECTS = device.o commands.o dumper.o msp430.o
HEADERS = cec.h
-CFLAGS = -Wall -g
+CFLAGS = -Wall -g -fPIC
.PHONY: all
diff --git a/lib/cec.h b/lib/cec.h
index a7cae44..acefd07 100644
--- a/lib/cec.h
+++ b/lib/cec.h
@@ -540,6 +540,7 @@ struct CEC_Device
uint8_t logical_address:4;
struct CEC_Physical_Address physical_address;
struct CEC_Hardware* hardware;
+ void* private_data;
void (*func_debug)(enum CEC_Debug debug, struct CEC_Device* device, struct CEC_Packet* packet);
void (*func_handler[0x100])(struct CEC_Device* device, struct CEC_Packet* packet);
diff --git a/lib/device.c b/lib/device.c
index 4805473..bf421f5 100644
--- a/lib/device.c
+++ b/lib/device.c
@@ -43,7 +43,7 @@ void CEC_Init_Device(struct CEC_Device* device)
int i;
for(i=0;i<0x100;i++)
- device->func_handler[i] = &CEC_Unrecognized_Opcode;
+ device->func_handler[i] = NULL;
}
void CEC_Receive(struct CEC_Device* device)
diff --git a/lib/msp430.c b/lib/msp430.c
index b2afd25..b74d3ec 100644
--- a/lib/msp430.c
+++ b/lib/msp430.c
@@ -53,9 +53,9 @@ static ssize_t Fill_Buffer(struct MSP430_Hardware* hw)
static int Buffer_Empty(struct MSP430_Hardware* hw)
{
- return hw->index < BUFFER_SIZE && (
- hw->buffer[hw->index] == 0 ||
- hw->buffer[hw->index] == 0xff);
+ return hw->index >= BUFFER_SIZE ||
+ hw->buffer[hw->index] < 8 ||
+ hw->buffer[hw->index] == 0xff;
}
static struct CEC_Packet* Receive(struct CEC_Device* device)
@@ -75,6 +75,7 @@ static struct CEC_Packet* Receive(struct CEC_Device* device)
void* packet = &(hw->buffer[hw->index]);
hw->index += hw->buffer[hw->index];
+ hw->index++;
if(hw->index > BUFFER_SIZE) return NULL;
return (struct CEC_Packet*)packet;
}
@@ -219,6 +220,8 @@ struct CEC_Hardware* MSP430_Open_Hardware(const char* device)
if(ioctl(result->i2c, I2C_SLAVE, I2C_ADDR) < 0)
goto error2;
+ result->index = BUFFER_SIZE;
+
return &(result->cec);
error2: