Jody
Joined: 08 Sep 2006 Posts: 182
|
puts sends not all the data??? |
Posted: Mon Mar 19, 2007 10:34 am |
|
|
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;
}
}
}
|
|
|