Datalink layer access

Discuss with MikroElektronika software developers about current library development.
Post Reply
Author
Message
peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

Datalink layer access

#1 Post by peterverkaik » 14 Jan 2013 08:05

Hi,

I would like to see datalink layer access functions,
much like UDP.

For example, the UDP called library function

sub function Net_Ethernet_28J60_UserUDP(dim udpDsc as ^UDP_28j60_Dsc) as word

could have a simular MAC called library function
sub function Net_Ethernet_28J60_UserMAC(dim macDsc as ^MAC_28j60_Dsc) as word
to handle incomng datalayer packets

And like UDP send function
sub function Net_Ethernet_28j60_sendUDP(dim destIP as ^byte, dim sourcePort as word, dim destPort as word, dim pkt as ^byte, dim pktLen as word) as byte

there would be a MAC send function
sub function Net_Ethernet_28j60_sendMAC(dim destMAC as ^byte, dim sourcePort as word, dim destPort as word, dim pkt as ^byte, dim pktLen as word) as byte

I used the term MAC as the MAC module deals with datalink layer.

The functions are most probably already in the library because the TCP/IP and UDP
are at the network layer which is above the datalink layer.

I would like to see these functions be made public so we can implement datalink layer
protocols like LLDP. LLDP is required for requesting more power from POE+ switches
and currently it is not possible to send packets to a specific MAC address at the datalink
layer. My proposal MAC functions would allow for that.

regards peter

peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

Re: Datalink layer access

#2 Post by peterverkaik » 17 Jan 2013 12:27

Hi,

Is there a way to retrieve packets received but not handled by the library?

The function doPacket() returns a word value
0 - upon successful packet processing (zero packets received or received packet processed successfully).
1 - upon reception error or receive buffer corruption. ENC28J60 controller needs to be restarted.
2 - received packet was not sent to us (not our IP, nor IP broadcast address).
3 - received IP packet was not IPv4.
4 - received packet was of type unknown to the library.

In case of values 2, 3 and 4
can we retrieve the received packet?
I can imagine that value 2 would be returned for a datalink packet
(eg. packet sent to our mac address).

If possible, how do I retrieve a received packet? Which registers identify
the packet and bufferspace ocupied by that packet?

regards peter

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Datalink layer access

#3 Post by dejan.odabasic » 17 Jan 2013 13:05

Hello,

In current implementation of Network library it's not possible to retrieve datalink layer packages.
Also, current abstraction level of library doesn't allow easy access to datalink layer.

I will present your suggestions to our developers and they will consider implementing function which will provide access to datalink layer.

Thank you for your suggestions.

Best regards.

peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

Re: Datalink layer access

#4 Post by peterverkaik » 06 Feb 2013 15:06

Hi,

The correct way to allow development of more protocols
is to have raw sockets.

Is it possible to have raw sockets, so we can put in a custom protocol type?
Or can I use a UDP socket and then overwrite the protocol type field?
How can I receive raw socket data?
I ask these questions with LLDP in mind.

regards peter

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Datalink layer access

#5 Post by dejan.odabasic » 07 Feb 2013 12:51

Hello,

I'm afraid that my last answer applies to your new set of questions.
Current implementation of Network library doesn't allow access to "raw data".

Thank you for understanding.

Best regards.

peterverkaik
Posts: 174
Joined: 31 Aug 2009 22:44

Re: Datalink layer access

#6 Post by peterverkaik » 07 Mar 2013 16:11

Hi,

Is it possible to get a callback function for a new received packet?

sub function Net_Ethernet_28J60_UserRaw(dim socket as Net_Ethernet_28J60_RawSocket) as word

If the function returns 0 than the packet is handled by the above function,
if it returns 0xFFFF than the Ethernet library calls userUDP() or userTCP() function
as it does now.

So any received packet is first offered to the userRAW() function.

It should take very little time to provide such a callback function
and allows us to receive layer 2 packets.

2nd question:
I noticed the subroutine Net_Ethernet_28J60_TxSend(dim l as word)
can be used in my program (so it appears to be public), but it is
not mentioned in the help file. Is there any info an all the subroutines
in the private mbas file?

regards peter

User avatar
darko.jola
Posts: 51
Joined: 03 Aug 2011 16:18

Re: Datalink layer access

#7 Post by darko.jola » 12 Mar 2013 16:09

Hi,
we can try to implement such function in some of future releases of libraries, thanks for your suggestion. But for now reading raw data is not possible.
About your 2nd question, did you mean "Net_Ethernet_28J60_Txpacket(dim l as word)"? Such function is used by library to send prepared packet over network, and user should not use this function.

Best regards
Darko

JMAT
Posts: 3
Joined: 27 Dec 2014 19:41

Re: Datalink layer access

#8 Post by JMAT » 12 Jan 2015 04:51

Hello, I have implemented a server in ATMEGA1284P but the system (atmega + enc28j60) freezes after some time :( .

All the time, I got the error code number 2 ( some times number 4) with Function doPackage. I do not what happens!!

Could you help me please?


Thanks so much!!
JMAT

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Datalink layer access

#9 Post by dejan.odabasic » 13 Jan 2015 16:03

Hello,

Have you tried to reset the ENC28J60 after receiving the corrupted packet?
Toggle of RST pin and initialization(Net_Ethernet_28j60_Init) should help you solve the problem.

Error codes are explained in library help file.
For more details, please take a look at ..compiler\Packages\Network_Ethernet_AVR\Help\ folder.

Best regards.

JMAT
Posts: 3
Joined: 27 Dec 2014 19:41

Re: Datalink layer access

#10 Post by JMAT » 17 Jan 2015 08:16

I will try reset the enc28j60 with the reset pin!
The help file does not help, neither case 2 or 4 say what should done!

Thanks so much

JMAT

Post Reply

Return to “Library Development Discussion”