#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++) {
- 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("\tChecksum: 0x%02x (%s)\n", buf[len-1],
+ (buf[len-1] == ipmb_csum(buf+3, len-4)) ? "OK" : "Wrong");
+ printf("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n");
}
int main(void)