CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Error PDU encode

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pilar



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

Error PDU encode
PostPosted: Wed Sep 07, 2016 7:23 pm     Reply with quote

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);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19506

View user's profile Send private message

PostPosted: Thu Sep 08, 2016 2:59 am     Reply with quote

Go to this site:
<http://www.smartposition.nl/resources/sms_pdu.html>

Put your message into the source tab.
Convert it.

How long is the output?. I count more than 100 characters....

Your target buffer needs to be at least 2*message length+1 characters.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group