]> git.zerfleddert.de Git - rsbs2/commitdiff
decode packets
authorMichael Gernoth <michael@gernoth.net>
Sun, 22 Aug 2010 18:53:18 +0000 (20:53 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sun, 22 Aug 2010 18:53:18 +0000 (20:53 +0200)
bmc/bmc.c
bmc/bmc.h [new file with mode: 0644]
bmc/i2c.c

index 4a7f02f489b2f45df33fee5e7ecf5876fc28efce..4db28a6fab3cb2c9408a38f7b39dcdd6da8cdc55 100644 (file)
--- a/bmc/bmc.c
+++ b/bmc/bmc.c
@@ -6,15 +6,40 @@
 #include "i2c.h"
 #include "bmc.h"
 
 #include "i2c.h"
 #include "bmc.h"
 
-void decode_bmc_cmd(unsigned char *buf, int len)
+uint8_t ipmb_csum(unsigned char *buf, int len)
 {
 {
+       uint8_t csum = 0x00;
        int i;
 
        for(i = 0; i < len; i++) {
        int i;
 
        for(i = 0; i < len; i++) {
-               printf("0x%02x ", buf[i]);
+               csum += buf[i];
        }
 
        }
 
+       return -csum;
+}
+
+void decode_bmc_cmd(unsigned char *buf, int len)
+{
+       int i;
+
+       printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+       printf("Connection Header:\n");
+       printf("\trs Slave Addr.: 0x%02x\n", buf[0]);
+       printf("\tnetFn: 0x%02x, LUN: 0x%02x\n", (buf[1]>>2)&0x3f, (buf[1] & 0x03));
+       printf("\tChecksum: 0x%02x (%s)\n", buf[2],
+               (buf[2] == ipmb_csum(buf, 2)) ? "OK" : "Wrong");
+       printf("Data:\n");
+       printf("\trq Slave Addr.: 0x%02x\n", buf[3]);
+       printf("\trqSeq: 0x%02x, rqLUN: 0x%02x\n", (buf[4]>>2)&0x3f, (buf[4] & 0x03));
+       printf("\tcmd: 0x%02x\n", buf[5]);
+       printf("\tData: ");
+       for(i = 6; i < (len - 1); i++) {
+               printf("0x%02x ", buf[i]);
+       }
        printf("\n");
        printf("\n");
+       printf("\tChecksum: 0x%02x (%s)\n", buf[len-1],
+               (buf[len-1] == ipmb_csum(buf+3, len-4)) ? "OK" : "Wrong");
+       printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
 }
 
 int main(void)
 }
 
 int main(void)
diff --git a/bmc/bmc.h b/bmc/bmc.h
new file mode 100644 (file)
index 0000000..99d5810
--- /dev/null
+++ b/bmc/bmc.h
@@ -0,0 +1 @@
+void decode_bmc_cmd(unsigned char *buf, int len);
index 7104758551a25b280296ea999091638557a56f00..4ada02e6c011ebf1cfd0e33c73563d2861885e05 100644 (file)
--- a/bmc/i2c.c
+++ b/bmc/i2c.c
@@ -29,6 +29,8 @@ ISR (TWI_vect, ISR_BLOCK)
                        printf("I2C: Slave 0x%02x adressed\n", TWDR);
 #endif
                        pos = 0x00;
                        printf("I2C: Slave 0x%02x adressed\n", TWDR);
 #endif
                        pos = 0x00;
+                       databuf[pos] = TWDR;
+                       pos++;
                        TWCR_ACK;
                        break;
 
                        TWCR_ACK;
                        break;
 
@@ -50,13 +52,6 @@ ISR (TWI_vect, ISR_BLOCK)
                        TWCR_RESET;
                        break;
 
                        TWCR_RESET;
                        break;
 
-               case TW_ST_SLA_ACK:
-               case TW_ST_DATA_ACK:
-                       printf("I2C: Data requested\n");
-                       TWDR = 0x00;
-                       TWCR_ACK;
-                       break;
-
                default:
                        printf("I2C: Unimplemented status 0x%02x\n", TW_STATUS);
                        TWCR_RESET;
                default:
                        printf("I2C: Unimplemented status 0x%02x\n", TW_STATUS);
                        TWCR_RESET;
Impressum, Datenschutz