pilar
Joined: 30 Jan 2008 Posts: 197
|
Error PDU encode |
Posted: Wed Sep 07, 2016 7:23 pm |
|
|
Hi,
I'm using this code http://www.ccsinfo.com/forum/viewtopic.php?t=34800&highlight=pdu to encode one PDU format a string, this works in some cases and in others a couple of characters at the end is lost, for more I try I can not find the error.
Someone can help me?
Here is my code:
Code: | #include <18F4620.h>
#DEVICE ADC=8
#fuses HS,WDT32768,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)// RS232 Estándar
#include <stdio.h>
#include <string.h>
int i,r,w;
int Long_Buffer;
int Long_Data_PDU;
char buffer[]="$GPSMS,862170014677098,18,23.99,14.99,4.99,3.29,VERT,OPEN,26.25,094559,010000,*"; //ERROR!
//char buffer[]="$GPSMS,862170014677098,18,23.99,14.99,4.99,3.29,NOVERT,OPEN,26.25,094546,010000,*"; //OK
char PDU_Buffer[100];
int main(){
Long_Buffer = strlen(buffer);
r = 0;
w = 0;
while (r<Long_Buffer) {
PDU_Buffer[w]=((buffer[r]>>(w%7))&0x7F) | ((buffer[r+1]<<(7-(w%7)))&0xFF);
if ((w%7)==6){
r++;
}
r++;
w++;
}
while (TRUE);
} |
|
|