Manual Packet Creation and More!
Just finished adding the ability to create a packet based on parameters rather than requiring a premade packet.
Manual Packets
Basicly, instead of needing something like ,
uint8_t input[] = {
0x05, 0x64, ...
};
dnp3p_st packet_s = mkPacket(input);
You can now just use a function and pass in parameters. Then, since this is just a fancy memory structure, a simple memcpy into an appropriately sized array will give you both! (The raw packet, and the structure)
uint8_t packet[30] = {0};
// did some renaming, uses dnp3Lib for library funcs now
dnp3p_st packet_s = dnp3Lib_mkPacket_manual(1, 0, 30, 2, 0, 10);
// params are: destination, source, group, variation, startIndex, and stopIndex
memcpy(&packet, &packet_s, 30);
This will give you basicly the same thing as the first example, meaning you can create a packet based on a discription, rather than a discription based on a packet.
This will be very useful when creating responses from to the client from the server, or vice versa.
Should be noted that this is technically not very complete, but it is just an example for now.
Pre-made Packets
On the topic of creating a packet based on a discription, I also created some functions to create packets for common messages, including;
- Reset Link
- Required when creating a new connection
- Acknowledgement
- Negative Acknowledgment
These will be useful when making connections, and sending responses to requests and replies.
Wrap Up
Still got a ways to go in terms of completion, but I’m hoping to ramp up my speed, been a little busy the past couple weeks.