void Recibir_Trama_Modbus(){
unsigned int ConRX_1, ConRX_2, Cont;
ConRX_2 = 0x001F;
ConRX_1 = 0x00FF; Cont = 0; Cont_valor_trama = 0;
while (Cont < 256){
if( int2 > 0){
Trama[Cont++] = Dato2;
ConRX_1 = 0x00FF; int2 = 0;
}
ConRX_1--;
if( ConRX_1 == 0 ){ ConRX_1 = 0x00FF; ConRX_2--;
if( ConRX_2 == 0 ){ Trama[Cont] = 0x00; Cont_valor_trama = Cont; Cont = 256; int2 = 0;}
}
}
// for(i=0;i<Cont_valor_trama;i++){ U2(Trama[i]); }
Interpretacion_Trama();
// for(i=0;i<Cont_valor_trama;i++){ Trama[i]=0; }
U2MODEbits.WAKE = 1; U1MODEbits.WAKE = 1;
}
void __attribute__ ((interrupt, no_auto_psv)) _U2RXInterrupt(void) {
int2 = 1;
Dato2 = U2RXREG;
IFS1bits.U2RXIF = 0;
}
void __attribute__ ((interrupt, no_auto_psv)) _T3Interrupt(void){
Accion_Alarma();
if( int2 > 0 ){_T3IE = 0; Recibir_Trama_Modbus();}
_T3IF=0;
}
struct{
UINT8 BufferRx[LENGTH_BUFFER_UART_RX]; ///< Buffer para recepcion de datos por medio del uart
UINT16 PtrRxRData; ///< Puntero para lectura de datos del buffer de recepcion
UINT16 PtrRxWData; ///< Puntero para escritura de datos al buffer de recepcion
UINT16 CountRxData; ///< Cuenta la cantidad de datos que hay almacenados en el buffer de recepcion
struct{
unsigned FullBufferRx:1; ///< En 1 indica que el buffer de recepcion esta lleno
}Flags;
}UARTData;
In file included from system.h:56:0,
from Main.c:1:
Protocolos.h:117:14: error: variably modified 'BufferRx' at file scope
uart.c: In function '_U2RXInterrupt':
uart.c:78:20: error: 'struct <anonymous>' has no member named 'BufferRx'
uart.c:78:30: error: 'DNPUARTData' undeclared (first use in this function)
uart.c:78:30: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [build/default/production/uart.o] Error 255
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
Me manda el siguiente error, al declarar LENGTH_BUFFER_UART_RX como UINT8 (unsigned char):
while(1){
if(!S3){ __delay_ms(200)
UA2("CONT");U2(UARTDato.CountRxData);UA2("CONT ");
UA2(" FLAG");U2(UARTDato.Flags.FullBufferRx);UA2("FLAG");
for(i=0; i<UARTDato.CountRxData; i++){
U2(UARTDato.BufferRx[i]);
}
}
if(!S4){__delay_ms(200)
for(i=0; i<UARTDato.CountRxData; i++){
UARTDato.BufferRx[i]=0;
}
UARTDato.CountRxData = 0;
UARTDato.Flags.FullBufferRx = 0;
}
}
void __attribute__ ((interrupt, no_auto_psv)) _U2RXInterrupt(void) {
// int2 = 1;
// Dato2 = U2RXREG;
if(UARTDato.Flags.FullBufferRx == 0){ // Si el buffer no esta lleno almaceno
UARTDato.BufferRx[UARTDato.PtrRxWData++]=U2RXREG;
if(++UARTDato.CountRxData==LENGTH_BUFFER_UART_RX){ // Verifico si se llena buffer
UARTDato.Flags.FullBufferRx=1;
}
if(UARTDato.PtrRxWData==LENGTH_BUFFER_UART_RX){ // Es un buffer circular, reinicio puntero si es necesario
UARTDato.PtrRxWData=0;
}
}
IFS1bits.U2RXIF = 0;
}
void __attribute__ ((interrupt, no_auto_psv)) _U2RXInterrupt(void) {
if( UARTDato.Flags.FullBufferRx == 0 ){ // Si el buffer no esta lleno almaceno
D9 = 1;
UARTDato.BufferRx[UARTDato.PtrRxWData++] = U2RXREG;
if( UARTDato.PtrRxWData == (LENGTH_BUFFER_UART_RX + 1) ){
UARTDato.Flags.FullBufferRx = 1;
}
}
IFS1bits.U2RXIF = 0;
}
void UARTGetArray(UINT8 *PtrData,UINT16 Lenght){
UINT16 k;
for( k=0;k<Lenght;k++ ){
*PtrData++ = UARTDato.BufferRx[k];
U2(UARTDato.BufferRx[k]);
}
UARTDato.Flags.FullBufferRx = 0;
UARTDato.PtrRxWData = 0;
}
void __attribute__ ((interrupt, no_auto_psv)) _T3Interrupt(void){
UINT16 a;BYTE grup[20];
a = UARTDato.PtrRxWData;
UARTGetArray( &grup[0], a );
_T3IF=0;
}
void __attribute__ ((interrupt, no_auto_psv)) _U2RXInterrupt(void) {
int2 = 1;
D10 = 1;
TMR1 = 0;
if(UARTDato.Flags.FullBufferRx == 0){
if( UARTDato.Flags.FullBufferRx == 0 ){ // Si el buffer no esta lleno almaceno
UARTDato.BufferRx[UARTDato.PtrRxWData++] = U2RXREG;
if( UARTDato.PtrRxWData == (LENGTH_BUFFER_UART_RX + 1) ){
UARTDato.Flags.FullBufferRx = 1;
}
}
}
if(UARTDato.Flags.FullBufferRx == 1){
//_T1IE = 0;
UARTDato.Flags.FullBufferRx = 0;
UARTDato.PtrRxWData = 0;
}
IFS1bits.U2RXIF = 0;
}
void __attribute__ ((interrupt, no_auto_psv)) _T1Interrupt(void){
Recibir_Trama_Modbus();
_T1IF = 0;
}
void Recibir_Trama_Modbus(){
BYTE i;
BYTE grup[20];
a = UARTDato.PtrRxWData;
UARTGetArray( &Trama[0], a );
Interpretacion_Trama();
for(i=0; i<a; i++){
Trama[i] = 0;
}
//Se limpian todas las variables
D10 = 0;
UARTDato.PtrRxWData = 0;
a = 0;
int2 = 0;
Cont_Trama_Resp = 0;
DataAddressMOD = 0;
LenghtMOD = 0;
CRCMOD = 0;
U2MODEbits.WAKE = 1; U1MODEbits.WAKE = 1;
}