00001
00021 #include <stdlib.h>
00022 #include <stdio.h>
00023 #include <unistd.h>
00024 #include "sportident.h"
00036 int WriteRaw( const si_station * station, unsigned char* buffer, int len)
00037 {
00038 unsigned int i, crc;
00039 char* buff;
00040
00041 buff=(char*)malloc(sizeof(char)*(len+6));
00042 buff[0]=0xFF;buff[1]=0x02;buff[2]=0x02;
00043 for(i=3;i<len+3;++i) buff[i]=buffer[i-3];
00044 crc=SiCrc((unsigned int) len, buffer);
00045 buff[len+3]=(crc&0xff00)>>8;
00046 buff[len+4]=crc&0x00ff;
00047 buff[len+5]=0x03;
00048 return write(station->fd, buff, len+6)-6;
00049 }