Data aqusition using picserialdrv.c

I’m trying to get the serial driver to work to collect and parse data in realtime. Right now i want to get the driver to be able to read off a value from the serial port and send it to the computer using hyperterminal or something.
I’ve tried adding my own routine to the driver and it says that there’s a syntax error
the code is as follows:

void Serial_Char_Callback(dcb[PROGRAM_PORT].myRCREG)
{
char ctd[10];
int i;
for(i = 0; i < 10; i++)
{
ctd
= dcb[PROGRAM_PORT].myRCREG;
printf("%d", ctd
);
if(i == 9)
{
printf("\n");
}
}
}**

What program are you using?

Mplab 7.2 w/ the pic 2.4 compiler

I tried using a char and it still came up with a syntax error

Did you enclose the type in parentheses, i.e. “(char)”?

What PIC18 C compiler error message do you get in the status window?

I changed the function declaration to:

void Serial_Char_Callback(char salt)

with the function call being:

Serial_Char_Callback(*dcb[PROGRAM_PORT].myRCREG);

Which comes out with these error messages

C:\Documents and Settings\VexCode\PicSerialDrv.c:430:Error [1109] type mismatch in redeclaration of ‘Serial_Char_Callback’
C:\Documents and Settings\VexCode\PicSerialDrv.c:436:Error [1130] pointer operand required for ‘*’ operator
C:\Documents and Settings\VexCode\PicSerialDrv.c:436:Error [1131] type mismatch in assignment

I looked at the DDT code provided by IFI and they declare the function as:
void Serial_Char_Callback(unsigned char data);

so the type was not “char” but “unsigned char”.

Thanks i got it to compile. :smiley:
When i went to input data using hyperterminal except it wouldn’t react to the input. I want to get the microcontroller to be able to recieve data from the computer and print it back out to the screen. I want to assign values to the microcontroller array ctd using hyperterminal using the picserialdrv.c. And then get it to print back out again. Is this the correct way to do it?

void Serial_Char_Callback(unsigned char data) 
{
	char ctd[10], enter="\n";
	int i;
	for(i = 0; i < 10; i++)
	{
		ctd* = data;
	}
	for(i = 0; i < 10; i++)
	{
		Serial_Write_Char(PROGRAM_PORT, ctd*);
		if(i == 9)
		{
			Serial_Write_Char(PROGRAM_PORT, enter);
		}
	}
}	
void Serial_Write_Char(int port,unsigned char ch_out) 
{
  static DeviceStatusPtr dcbPtr;

  dcbPtr = &dcb[port];

  *dcbPtr->myTXREG = (unsigned char) ch_out;  /* Load transmit register with data */

  if (port == PROGRAM_PORT)
    while (!TXINTF);
  else
    while (!TXINTF2);
}

**

It turns out i was dealing with a bad unpacking of the source code so that it would not function properly the the serial driver works fine now. Thank you guys for all your help. My function ended up as:

void read_ctd(char data)
{
	int output, ctddata[MAXDATA], i;
	static char bufferptr, dataptr;
	if(dataptr<MAXDATA)
	{           
        if(bufferptr<MAXCTD)
	    {
             ctdbfr[bufferptr] = data;
		     bufferptr++;
  	    }
  	    if(ctdbfr[bufferptr-1]=='.')
  	    {
	  	    ctdbfr[bufferptr-1]=ctdbfr[bufferptr];
	  	    bufferptr--;
	    }
        if(data == '\n' || data == '\r')
	    {
	        ctdbfr[bufferptr-1] = 0;
		    output = atoi(ctdbfr);
		    ctddata[dataptr]=output;
		    printf("output = %d\n", ctddata[dataptr]);
		    printf("dataptr is %d\n", dataptr);
		    bufferptr = 0;
		    dataptr++;
            }
        
        if(dataptr==MAXDATA)
        {
	        for(i=0; i<MAXDATA; i++)
	        {
		        printf("array element %d %d, ", i, ctddata*);
		    i++;
		    if(i==9)
		    {
			    printf("\n");
			    i=0;
		     }
		 }
	         dataptr=0;
	         printf("array cleared\n");
	    }  
	}
}