As I'm working on another project, I'm running in to problems trying to pass a structure to an event handler.
Eventually, I'll have 3 UARTS receiving packets and decoding them, so i'm trying to make a common routine I can call for all three.
I've passed structures before. It doesn't seem to like the interrupt routine I guess.
Here's a test program and module. When I compile, I get 'Invalid variable type : header_t' errors.
Main Program:
- Code: Select all
'P24 Event Test
imports P24EventMod
public structure header_t
Command as byte
Length as ushort
RcvdChksum as ushort
CalcChksum as ushort
valid as boolean
end structure
Public dim Testheader as header_t
'****************************************************************************
' This event handler is triggered when data is received
'****************************************************************************
public Sub OnData1(byref hdr as header_t, ByRef Data As Byte) Handles P24EvMod.OnData1
Dim DataIn As Byte = Data
With hdr
.Length = &h1234
.command = Data
end with
End Sub
/* Main program...*/
Sub Main()
While true
End While
End Sub
and the test module:
- Code: Select all
'Event module for Event Test
Module P24EvMod
'Declaration
Public Event OnData1(byref hdr as header_t, ByRef data As Byte)
'Interrupt code
private Interrupt OnRX1(Pic.U1RXInterrupt)
' read a data byte from the USART...
Dim byteRead As Byte = U1RXREG.Byte0
RaiseEvent OnData1(TestHeader,byteRead) ' call the event handler
IFS0.11 = 0
End Interrupt
End Module