filtering received messages via rs232

Thread Starter

turku_as

Joined May 6, 2012
3
hi,

i am working on a mcu circuit that can communicate another device, and it receives so many message lines. My mcu doesnt have enough ram to store all message lines. So, i tried the code below with my pic18f4550 and 48 mhz clock to filter the message lines and pick the required values from the streaming message.

Rich (BB code):
static char message[25];
static char value_required[25]
staric char *ptr;
static int1 value_get = FALSE;

char filter[] = "filter_value";

void main (void)
{

puts("some_command");

while(value_get == FALSE)
{
gets(message);
ptr = strstr(message,filter);
if(ptr != NULL)
{
strcpy(value_required,message);
value_get = TRUE;
lcd_putc(value_required);
}
}
}
when i try to run this code , nothing happens. i know it gets values but never filters and sends to lcd.

i am a little concerned about the clock rate, 48 mhz is enough to run string functions while getting characters at 9600 baud ? or i am using the wrong function?
Rich (BB code):
Rich (BB code):
Rich (BB code):
Rich (BB code):
Rich (BB code):
 

Thread Starter

turku_as

Joined May 6, 2012
3
You have to post your real code. There are two many things that get altered in the translation.
here is my code, and i am using 20mhz xtal.

Rich (BB code):
#include <18f2550.h>
#include <string.h>


#fuses HSPLL, NOWDT, PLL5, CPUDIV1, USBDIV, NOXINST 
#use delay (clock=48000000) 
#use rs232(baud=300,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=7,STOP=1)

#include "lcd.c"

#ifndef FASTER_BUT_MORE_ROM
#define FASTER_BUT_MORE_ROM

#ifndef INTERNAL_EEPROM_UTILITIES
#define INTERNAL_EEPROM_UTILITIES

#ifndef INT_EEPROM_ADDRESS
#define INT_EEPROM_ADDRESS  int8
#endif

static char message[25];
static char value_required[25]
staric char *ptr;
static int1 value_get = FALSE;

char filter[] = "filter_value";

void main (void)
{

puts("some_command");

while(value_get == FALSE)
{
gets(message);
ptr = strstr(message,filter);
if(ptr != NULL)
{
strcpy(value_required,message);
value_get = TRUE;
lcd_putc(value_required);
}
}
}
 

Thread Starter

turku_as

Joined May 6, 2012
3
Did you attempt to run this code? There are spelling errors.
no, i didnt run this code, i didnt write my original code because it contains a lot of variables and other functions which are not related to my problem.

also it is too large to read, and those functions dont effect my pic to work correctly. my problem is to read lines and pick the line containing the value i want to store to eeprom;

so, do you know how i can read the lines correctly and pick the specific one?

and also my original code can be compiled properly and no problem occours, so you can ignore the syntax errors.
 

MrChips

Joined Oct 2, 2009
30,810
Ok, the best way to debug code is to compile and run it.
It is not the same to analyze a hypothetical situation.
If you are attempting to debug a single feature of a much larger system, create an abridged project that focuses on the single issue. It would be futile to help you otherwise.
 

t06afre

Joined May 11, 2009
5,934
It would also help if you gave us some information on the protocol used. If you keep secrets about your project. It will be very hard to help you
 
Top