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 support@ccsinfo.com

puts sends not all the data???

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



Joined: 08 Sep 2006
Posts: 182

View user's profile Send private message Send e-mail

puts sends not all the data???
PostPosted: Mon Mar 19, 2007 10:34 am     Reply with quote

Hello,

When I send data whith the puts command I receive only a few characters...??? But when I look at the variabels with the ICD I see that they have the correct data.... what am I missing??
I added the code:
Code:

#include "L:\Afstand_schatting\Afstand_Schatting.h"
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <input.c>

#define  HARTBEAT                   PIN_D0
#define  POLY                       0x0107
#define  CRC_INIT                   0x00

typedef unsigned char   CRC_TYPE;
int1                    string_ready   = FALSE;
BYTE                    next_in        = 0;
char                    string[45];
char                    string_copy[45];
char                    delimiters[2];
char                    *ptr;
char                    objectnr[1];
char                    cmd[10];
char                    arg1[6];
char                    arg2[6];
char                    arg3[6];
char                    arg4[6];
int16                    crc_calculated;
char                    crc_received[2];

#int_RDA
RDA_isr()
{
   string[next_in]=getc();

   if(string[next_in] == '\n')   //Einde string
   {
     string[next_in] = '\0';
     output_toggle(HARTBEAT);
     string_ready = TRUE;
   }

   next_in=(next_in+1);
}


void main()
{
int8 lengte       = 0;
int16 i            = 0;

   setup_ccp1(CCP_PWM);   // Configure CCP1 as a PWM at RC2
   setup_ccp2(CCP_PWM);   // Configure CCP2 as a PWM at RC1
   setup_ccp3(CCP_PWM);   // Configure CCP3 as a PWM at RG3
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF|ADC_TAD_MUL_0);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_spi2(FALSE);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DIV_BY_16,255,1);
   setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
   setup_timer_4(T4_DISABLED,0,1);
   setup_comparator(F6_F5_F4_F3_OUT_ON_F2_F1);
   setup_vref(FALSE);
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);
   setup_low_volt_detect(FALSE);
   setup_oscillator(False);

   set_pwm1_duty(200);
   set_pwm2_duty(800);

   while(1)
   {

    /*  for(i = 0; i<1023> 55)
      {
       next_in =0;
      }

      if(STRING_READY == TRUE)
      {
         STRING_READY = FALSE;
         lengte = STRLEN(string);
         lengte = lengte - 3;
         strncpy(string_copy, string, lengte);
         string_copy[lengte] = '\0';
         crc_calculated = generate_8bit_crc(string_copy, lengte-1, 0x107);
//         printf("Calculated CRC: %x\n",crc_calculated);
         puts(crc_calculated);
         strcpy(delimiters," ");

         ptr = strtok (string, delimiters);
         strcpy(objectnr,ptr);
         puts(objectnr);
//printf("Objectnummer:\n");
         ptr = strtok (0, delimiters);
         strcpy(cmd,ptr);
//printf("Command:\n");
         puts(cmd);

         ptr = strtok (0, delimiters);
         strcpy(arg1,ptr);
//printf("Argument1:\n");
         puts(arg1);

         ptr = strtok (0, delimiters);
         strcpy(arg2,ptr);
//printf("Argument2:");
         puts(arg2);

          ptr = strtok (0, delimiters);
         strcpy(arg3,ptr);
//printf("Argument3:\n");
         puts(arg3);

         ptr = strtok (0, delimiters);
         strcpy(arg4,ptr);
//printf("Argument4:\n");
         puts(arg4);

           ptr = strtok (0, delimiters);
         strcpy(crc_received,ptr);
//printf("Crc_received:\n");
         puts(crc_received);

         next_in = 0;
      }
   }
}
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