Welcome, Guest
Username: Password: Secret Key Remember me

TOPIC: getting Compilation Error "EVENT_ONDATA2_0" not found

getting Compilation Error "EVENT_ONDATA2_0" not found 4 years 9 months ago #16938

  • kamlaa
  • kamlaa's Avatar
  • Offline
  • Fresh Boarder
  • Posts: 5
please help my below code doesn't compile. its giving error "EVENT_ONDATA2_0" not found
Device = 18F46J50
Clock = 48
Config OSC = HSPLL
Config PLLDIV = 5, 'PLL division
       CPUDIV = OSC1,                     ' 48MHz cpu clock
       FCMEN = OFF,
       IESO = OFF,
       //WDTEN = OFF,  //watch dog timer off
       WDTEN = ON,   //watch dog timer on
       WDTPS = 32768,
       STVREN = ON,
       XINST = OFF, 
       CP0 = ON,
       IOL1WAY = OFF

#option SD_SPI = SW
#option SD_SPI_SPEED = spiOscDiv4  
#option SD_CS = PORTC.2       // SPI CS To SD CS (SD pin 1)
#option SD_DI = PORTD.2       // SPI SDO to SD DI (SD Pin 2)
#option SD_CLK = PORTC.1      // SPI SCK To SD CLK (SD Pin 5)
#option SD_DO = PORTD.3       // SPI SDI To SD DO (SD Pin 7) 
#option SD_SUPPORT_SUB_DIRECTORIES = True
#option SD_SUPPORT_MULTIPLE_FILES = True

#option RX2_BUFFER_SIZE = 255
#option RX2_PRIORITY = ipHigh

#option USART2_BRGH = false
#option ENC28J60_CS = PORTB.2
#option ENC28J60_RST = PORTB.3
#option NET_ICMP = true   // enable ping 
#option NET_DHCP = true   // enable Dynamic Host Configuration Protocol (DHCP)
#option NET_NBNS = true   // enable NETBIOS
#option NET_TCP = true    // enable TCP

#option DEBUG = true

Include "NETApp.bas"      // always first!
// TCPIP stack specifics...
Include "NETTypes.bas"
Include "NETUtils.bas"
Include "Tick.bas"
Include "TCP.bas"
                        
'Include "SDFileSystem_old.bas"
Include "SDFileSystem.bas" //new sdfile system with db
Include "usart2_rp.bas"
Include "ISRRX2-modbb.bas"   
Include "Convert.bas"   
Include "string.bas" 

// program helpers...
Include "NETAppDisplay.bas"
Include "suart.bas"
Include "convert.bas"
Include "HTTPClient.bas"

Const MaxSockets = MAX_TCP_SOCKETS // found in NETConfig, default is eight 
Const
   SM_HOME = 0,
   SM_LISTENING = 1
Const dbData = 0
Const dbFileName = "file.db"

Dim GSMControl As PORTA.3
Dim GSMStat As PORTA.2
Dim GSMReset As PORTB.1

    Dim ITemp2 As Char
 //====================== 
// structure that holds socket state, connected flag and 
// TCP socket ID...   
Structure TSocket
   State As Byte
   Connected As Boolean
   ID As TCP_SOCKET
   dummy As Byte // 4 byte align
End Structure       

// TCP server socket array...
Dim Sock(MaxSockets) As TSocket
           

Sub SwitchOnProc() //device switch on procedure 
    If GSMStat = 1 Then
        High(GSMReset)
        DelayMS(200)
        Low(GSMReset)
    EndIf
    While GSMStat = 0
        High(GSMControl)
    Wend
End Sub

//======================

{
****************************************************************************
* Name    : TCPServerInit                                                  *
* Purpose : Prepare socket array                                           *
****************************************************************************
}
Sub TCPServerInit()
   Dim Index As Byte
   Dim Socket As TSocket
   For Index = 0 To MaxSockets - 1
      Socket.ID = INVALID_SOCKET 
      Socket.Connected = false
      Socket.State = SM_HOME
      Sock(Index) = Socket
   Next
End Sub  
{
****************************************************************************
* Name    : TCPServerOpen                                                  *
* Purpose : Open for listening 'MaxSockets' TCP sockets                    *
****************************************************************************
}
Sub TCPServerOpen()
   Const SERVER_PORT = 80'9760
   Dim Index As Byte
   Dim Socket As TSocket
   For Index = 0 To MaxSockets - 1
      Socket = Sock(Index)
      If Socket.ID = INVALID_SOCKET Then
         Socket.ID = TCPListen(SERVER_PORT)
         If Socket.ID <> INVALID_SOCKET Then
            Socket.State = SM_LISTENING
         EndIf
      EndIf
      Sock(Index) = Socket
   Next
End Sub 
    
{
****************************************************************************
* Name    : TCPServerTask                                                  *
* Purpose : Process the TCP server sockets                                 *
****************************************************************************
}     
Sub TCPServerTask()
   Dim c As Byte
   Dim Index As Byte
   Dim Socket As TSocket

   For Index = 0 To MaxSockets - 1 
      Socket = Sock(Index)

      // server socket allocated...
      If Socket.State = SM_LISTENING Then

         // see if a client has disconnected...
	 If Not TCPIsConnected(Socket.ID) Then
	    If Socket.Connected Then
	       Socket.Connected = false
               'UART.Write("Client ", DecToStr(Socket.ID), " disconnected",13,10)
            EndIf
	    Sock(Index) = Socket
            Continue
         EndIf

         // see if a client has just connected...
         If Not Socket.Connected Then
            Socket.Connected = true
            'UART.Write("Client connected, ")
            TCPGetRemoteInfo(Socket.ID)
            'UART.Write("IP address is ")
            DisplayIPAddress(TCP.RemoteInfo.Remote.IPAddr)
         EndIf

	 // receive and display any bytes sent...
	 If TCPIsGetReady(Socket.ID) <> 0 Then
	    While TCPGet(Socket.ID, c)
	       UART.Write(c)
	    Wend
            UART.Write(13,10)

	    // transmit  a reply...
	    If TCPIsPutReady(Socket.ID) <> 0 Then
	       TCPPutString(Socket.ID,"Hello...")
	    EndIf                             
         EndIf
      EndIf 
      Sock(Index) = Socket
   Next     
End Sub 

Event OnData2()
   
End Event

ISRRX2.Initialize(OnData2)


EECON2 = $55
EECON2 = $AA
PPSCON.0 = 0
RPINR16  = 23
RPOR24    = 5
EECON2 = $55
EECON2 = $AA
PPSCON.0 = 1
           
OSCTUNE.6 = 1 'PLLEN=1 -> PLL ENABLED
USART2.SetBaudrate(br19200)
OSCCON.7 = 1
ADCON1 = $07
ANCON0 = $FF                  // Default all pins to digital 
ANCON1 = $FF   

UART.SetBaudrate(sbr38400)
UART.SetTX(PORTB.7)
UART.SetRX(PORTB.6)
UART.SetMode(umTrue)

If SD.Init() = errOK Then
    If Not SD.FileExists(dbFileName) Then
        SD.QuickFormat()
        SD.NewFile(dbdata, dbFileName)
        SD.CloseFile(dbdata)
    EndIf
    SD.OpenFileRW(dbdata, dbFileName, 221)
EndIf

TCPServerInit()
TCPServerOpen()  

SwitchOnProc()

While true   
    
    ASM  //clear wdt 
        ClrWDT
    End ASM
    
    If ISRRX2.BufferOverrun Or ISRRX2.Overrun Then
	  ISRRX2.Reset
    EndIf
    
    NETApp.Task
    TCPServerTask()
    
    #if NET_DHCP
        If NETApp.DHCPEvent() Then

        EndIf
    #endif
    
    While ISRRX2.DataAvailable
        ITemp2 = ISRRX2.ReadByte
       Wend
    
Wend

getting Compilation Error "EVENT_ONDATA2_0" not found 4 years 9 months ago #16939

  • jmessina
  • jmessina's Avatar
  • Offline
  • Senior Boarder
  • Posts: 44
  • Thanks received: 189
It's hard to say what the issue is, but you may have a hard time fitting all that code into the 64K of a 46J50. Both the network stack and SD filesystem are fairly large on their own.

Try compiling for a larger chip (128K) and see what happens.
Time to create page: 0.266 seconds