Ethernet Realtime Linux Driver Code
Brought to you by:
l-crisan
File | Date | Author | Commit |
---|---|---|---|
axienet | 2024-07-01 | l-crisan | [r1] Initial version |
macb | 2024-07-01 | l-crisan | [r1] Initial version |
Readme.md | 2024-07-01 | l-crisan | [r2] Readme added |
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sstream>
#include <unistd.h>
#include <sys/ioctl.h>
//Set timeouts
#define MACB_RT_SET_R_TIMEOUT _IOW('a', 1, int32_t)
#define MACB_RT_SET_W_TIMEOUT _IOW('b', 2, int32_t)
//Get timeouts
#define MACB_RT_GET_R_TIMEOUT _IOR('e', 5, int32_t)
#define MACB_RT_GET_W_TIMEOUT _IOR('d', 4, int32_t)
int main(int argc, char* argv[])
{
cahr* ethernetFrame = ...;
int frameSize = ...;
int handle = open("/dev/eth0_rt". O_EXCL | O_RDWR);
ioctl(_handle, MACB_RT_SET_R_TIMEOUT, (int32_t*)&timeout);
ioctl(_handle, MACB_RT_SET_W_TIMEOUT, (int32_t*)&timeout);
write(handle, ethernetFrame, frameSize);
read((handle, ethernetFrame, frameSize);
close(handle);
}