Where is __NetEthInternal.mbas file

General discussion on mikroBasic PRO for PIC32.
Post Reply
Author
Message
ChuckR
Posts: 34
Joined: 26 Feb 2014 21:30

Where is __NetEthInternal.mbas file

#1 Post by ChuckR » 06 Jan 2017 23:50

I am using mikroBasic PRO for PIC32 and easyPIC Fusion board with PIC32MX795F512L w/Ethernet phy, I am using the Net_Ethernet_Internal library and it won't build when I use code that would require the __NetETHInternal.mbas file. For instance the example code in the help file shows these lines of code in this routine, I cut the extra code to keep it small....
sub function Net_Ethernet_Intern_UserUDP(dim udpDsc as ^UDP_Intern_Dsc) as word
if(udpDsc.destPort <> 2000) then
or
i = udpDsc.dataLength
or
result = udpDsc.dataLength

Also in the Net_Ethernet_Intern_startSendTCP example code you see this line....

if( (socket_global.state = 3) and (mark = 1) ) then

None of these lines will build, as I type them, when I type the "." I am offered a list containing the elements of the data structure. But when I try to build I always get an error like this ...
Message Number 304 Syntax Error: Expected ")" but "." found
Message Number 303 Identifier "destPort" was not declared

Basically I can't use anything that was in the structures of the file I can't find. I was wondering if I missed something where I was supposed to write an include statement for it, but I would have thought it should be automatic as part of the library.
When I searched my machine for it the closest thing I found was
/packages/Network_Ethernet_PIC/Uses/_NetEthInternalPrivate.mbas but this file does not appear to define the structures that I can't access.
I am very confused. :?

User avatar
uros.cvetinovic
mikroElektronika team
Posts: 803
Joined: 14 Dec 2015 09:24

Re: Where is __NetEthInternal.mbas file

#2 Post by uros.cvetinovic » 09 Jan 2017 16:20

Hi,

You need to add __NetEthInternal.h file to your project:
#include "__NetEthInternal.h"

If this doesn't help, please attach your whole project so I can check what could be the problem.

Best regards,

Uros

ChuckR
Posts: 34
Joined: 26 Feb 2014 21:30

Re: Where is __NetEthInternal.mbas file

#3 Post by ChuckR » 10 Jan 2017 02:35

Thanks for your help, when I added the include statement the compiler came back with file not found. I searched my entire hard drive and that file does not exist. I think maybe the distribution package for mikroBasic has an error. I need to use this library so I can send TCP data.

I think we are on the same page but just to make sure there isn't any confusion, this is not the library included with MikroBasic Pro, this is the additional library I downloaded from Libstock site.

Can you send me the file and tell me which directory it needs to be located in?
Thanks,
Chuck

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: Where is __NetEthInternal.mbas file

#4 Post by lana.arsic » 10 Jan 2017 14:52

Hi Chuck,

I'm sending you file in attachment, in mikroBasic its name is __Lib_NetEthInternal_Defs.mbas,
you can find it in Uses folder in installation folder of the package, for example in:
c:\Users\Public\Documents\Mikroelektronika\mikroBasic PRO for PIC32\Packages\Network_Ethernet_PIC32\Uses\.

You may also need to include Uses folder in Project -> Edit Search Paths...
If you still getting an error, please send your whole project in a zip/rar archive.

Best regards,
Lana
Attachments
__Lib_NetEthInternal_Defs.zip
(1.72 KiB) Downloaded 234 times

ChuckR
Posts: 34
Joined: 26 Feb 2014 21:30

Re: Where is __NetEthInternal.mbas file

#5 Post by ChuckR » 10 Jan 2017 20:44

My machine already had that file, I made sure that the path was in the project search paths. I added an include statement for the file but I am still unable to access those properties.
I have made a Zip file of my project as requested, there are a lot of things in my project but those that directly affect ENET are

LCU_Main calls MCUInit which sets up a timer interrupt to update "Net_Ethernet_Intern_UserTimerSec" and initialize the ENET connection. The main loop then calls "Net_Ethernet_Intern_doPacket()"

ENET2.mbas has the ENET code in it.

The RTCC module decrements a variable, when the variable reaches zero it resets the variable and calls "Net_Ethernet_Intern_startSendTCP(socketTCP)" this way the user can set how often to send data in seconds. My project reads this value from EEPROM. There is code in the timer1 Int routine that you can uncomment, it will cause data to be sent every few seconds.

The file Ethernet.mbas does not really affect ENET at all, I wrote code to transfer the data I wanted to send to another PIC using a soft UART because I thought I was having problems with libraries interfering with each other. It also does some work preparing the data I want to send and writes it into an array which is the data I send.

That said I have 2 problems, I am unable to access the properties of the socket and if the Ethernet cable is not connected the code crashes and the watchdog resets the PIC. I've tried several ways around this but have been unsuccessful.
If the enet cable is plugged in to a PC when the PIC boots it will send the data as soon as a host tries to connect to it, this works fine but after a while the socket changes to send and receive on Port 0, I believe this is caused by a broadcast message from the PC, if I could access the properties of the socket I think I could prevent this with a command that would reject anything not on port 3000.

I also found that I could display the data with a chrome browser by entering the IP address of the PIC "10.1.1.125" also the PC is set to "10.1.1.60". The PIC sends out to port 3000 but no response until another device talks to it, that socket is then used to send the data to the PC.

Thanks
Chuck
Attachments
LCU_FIN.zip
(1.3 MiB) Downloaded 281 times

ChuckR
Posts: 34
Joined: 26 Feb 2014 21:30

Re: Where is __NetEthInternal.mbas file

#6 Post by ChuckR » 11 Jan 2017 00:54

I have figured out one of the problems, you have to access the socket properties using a pointer. This will compile.

Code: Select all

   If (socket^.destPort = 3000) then
       SocketTCP = socket
    Else
      Exit
    End IF
This means the help included with this library is crap unless you can tell me why I can't get the example code to work.
I am still a bit of a NEWB and I am still trying to get a handle on pointers. This certainly wasn't obvious to me and I don't think there is any instance of doing it this way in the help.

I still need help figuring out how to keep it from freezing if the Ethernet is disconnected or turned off on the other end, the rest of my code needs to run anyway. My project is done if I can fix this. Instead of creating a connection with

Code: Select all

    while(i <> 1)
      i = Net_Ethernet_Intern_connectTCP(@remoteIpAddr, 3000, 3000, @socketTCP)
    wend
which looks like it will be an infinite loop if it can't connect.
How can I detect when another device has tried to connect with me? If they have then I will have a socket to work with and can allow my code to start sending back the data?

Thanks,
Chuck

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: Where is __NetEthInternal.mbas file

#7 Post by lana.arsic » 12 Jan 2017 09:50

Hi Chuck,

Our initial example is written assuming that the cable is connected and that you have Internet access.

If you want that project works when cable is not connected, you can add additional part
of code where you will check when you send some byte if you get response (i.e. if the server is alive)
and you can add that part in while loop.

Help file is made so it covers explanation for basic example, but please understand,
we cannot cover all the cases that users are planning to implement.

Best regards,
Lana

Dominic75
Posts: 87
Joined: 05 Oct 2012 23:37
Location: Quebec, Canada

Re: Where is __NetEthInternal.mbas file

#8 Post by Dominic75 » 29 Oct 2021 13:57

If you want that project works when cable is not connected, you can add additional part
of code where you will check when you send some byte if you get response (i.e. if the server is alive)
and you can add that part in while loop.


And how would that be possible since the library hangs directly in Net_Ethernet_Intern_Init ? How can you check for packets if you can't even pass the initialize? I mean this should just time out after a few seconds. Now it just freezes and I don't have any other option then to reset the microcontroller.

Post Reply

Return to “mikroBasic PRO for PIC32 General”