You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Cross net multicast: append 4 bytes:[src_net, src_mac, mh, ml]
Notes:
mh + ml: multicast_id, ml is mapped to mac layer multicast address (h: high byte, l: low byte);
Could simply use MULTI_NET = 0 and MULTICAST = 0 for local net multicast and broadcast.
Implementations of MULTI_NET and MULTICAST are optional.
PORT_SIZE:
Bit2
Bit1
SRC_PORT
DST_PORT
0
0
Default port
1-byte
0
1
1-byte
Default port
1
0
1-byte
1-byte
1
1
2-byte
2-byte
Notes:
The default port is0xcdcd for convention and doesn't consume space.
Append bytes forsrc_port beforedst_port.
Implementation of 2-byte port is optional.
Recommendation for first byte of payload
For Request and Report, the first byte definition:
FIELD
DESCRIPTION
[7]
is_reply, always 0
[6]
not_reply
[5:0]
sub command
For Reply, the first byte definition:
FIELD
DESCRIPTION
[7]
is_reply, always 1
[6:0]
status, 0 means no error
Port Allocation Recommendation
Ports 0 to 0xf are recommended for general purposes.Specifically, port 1 is designated for device information queries.While all ports in this section are optional, it is advisable to implement the basic function of port 1 (read device_info).
Port 1
Provide device info.
Types: - mac_start and mac_end: uint8_t - max_time: uint16_t (unit: ms) - "string": variable-length string, including empty string (excluding the terminating null byte '\0')Read device_info string: Write [0x00] Return [0x80, "device_info"]Search devices by filters (for resolving mac conflicts): Write [0x10, max_time, mac_start, mac_end, "string"] Return [0x80, "device_info"] after a random time in the range [0, max_time] only if "device_info" contains "string" (always true for an empty string) and the current mac address is in the range [mac_start, mac_end] (inclusive) Not return otherwise and reject any subsequent modify mac (or save config) commands
Example ofdevice_info: M: model; S: serial id; HW: hardware version; SW: software version ... Field order is not important; it is recommended to include the model field at least.
CDNET Address String Formats
localhost local link unique local multicast 10:00:00level0: 00:NN:MMlevel1: 80:NN:MM a0:NN:MM f0:MH:ML
For transferring large data, such as transmitting a jpg image in thecdcam project, the sub command is defined as follows:
[5:4] FRAGMENT: 00: not fragment, 01: first, 10: more, 11: last, [3:0]: cnt
Here, thecnt value corresponds to 0 for the first packet, and increments by 1 for each subsequent packet.
If flow control is required, for example, we can group every 12 packets as a transmission set,where only the last packet in each set hasnot_reply set to 0. Start by transmitting 2 sets of packets,wait for a reply regarding the last packet in the first set, and then append another set of packets.
For sub commands that do not have acnt definition like the one mentioned above,if we want to ensure the uniqueness of a command, such as ensuring that a command can only be executed once,we can also achieve this by cyclically sending commands through multiple source port numbers.
This way, if a command does not receive a reply, resend the command.The receiving port checks whether the source port number of the received command matches that of the previous command;if they match, the command is not executed again.
About
CDNET Protocol and CDBUS / CDNET C Library (The library is MCU-oriented.)