当前位置:网站首页>Soem EtherCAT source code analysis attachment 1 (establishment of communication operation environment)
Soem EtherCAT source code analysis attachment 1 (establishment of communication operation environment)
2022-07-05 08:04:00 【Changjiang houlang blog】
Convenience for programming and debugging needs ,windows The platform is an ideal platform .
The early code analysis will adopt the following platforms :
System environment :Win10
Compile environment :QT5.8.0
Network card communication interface installation package :WpdPack_4_1_2
QT Project code :
QT += core
QT -= gui
CONFIG += c++11
TARGET = WincapTest
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH += $$PWD/../Wincap/Include
DEPENDPATH += $$PWD/../Wincap/Lib
LIBS += -L$$PWD/../Wincap/Lib/ -lpacket
LIBS += -L$$PWD/../Wincap/Lib/ -lwpcap
The running source code is as follows :
#include <QCoreApplication>
#include<QDebug>
#include "pcap.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
pcap_if_t *alldevs;
pcap_if_t *d;
int getSize=0;
char errbuf[PCAP_ERRBUF_SIZE];
if(pcap_findalldevs(&alldevs,errbuf)==-1)
{
qDebug()<<errbuf;
}
for(d=alldevs;d;d=d->next)
{
qDebug()<<++getSize<<d->name;
if(d->description)
qDebug()<<d->description;
else
qDebug()<<"No description available ";
}
if(0==getSize)
{
qDebug()<<"No interfaces found!Make sure WinPcap is installed";
}
pcap_freealldevs(alldevs);
return a.exec();
}
The operation effect is shown below :
You can see that the computer network card prints out normally , The loaded network card catcher works normally .
边栏推荐
- Connection mode - bridge and net
- Create inf module in AMI code
- Live555 push RTSP audio and video stream summary (I) cross compilation
- Global and Chinese market for blood typing 2022-2028: Research Report on technology, participants, trends, market size and share
- C # joint configuration with Halcon
- MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
- UEFI development learning 3 - create UEFI program
- Global and Chinese markets for waste treatment air switches 2022-2028: Research Report on technology, participants, trends, market size and share
- Bluetooth hc-05 pairing process and precautions
- Wifi-802.11 negotiation rate table
猜你喜欢
Introduction of air gap, etc
研究发现,跨境电商客服系统都有这五点功能!
Altium designer learning (I)
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
Matlab2018b problem solving when installing embedded coder support package for stmicroelectronic
Halcon's practice based on shape template matching [1]
Ads usage skills
Relationship between line voltage and phase voltage, line current and phase current
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
UEFI development learning 6 - creation of protocol
随机推荐
MLPerf Training v2.0 榜单发布,在同等GPU配置下百度飞桨性能世界第一
Cadence simulation encountered "input.scs": can not open input file change path problem
[trio basic tutorial 16 from introduction to proficiency] UDP communication test supplement
Live555 RTSP audio and video streaming summary (II) modify RTSP server streaming URL address
Connection mode - bridge and net
Hardware and software solution of FPGA key chattering elimination
WiFi wpa_ Detailed description of supplicant hostpad interface
Class of color image processing based on Halcon learning_ ndim_ norm. hdev
Global and Chinese market of urban rail connectors 2022-2028: Research Report on technology, participants, trends, market size and share
生产中影响滑环质量的因素
[popular science] some interesting things that I don't know whether they are useful or not
万字详解八大排序 必读(代码+动图演示)
C language enhancement -- pointer
Extended application of single chip microcomputer-06 independent key
C language uses arrays to realize the intersection, union, difference and complement of sets
Programming knowledge -- basis of C language
Altium designer 19.1.18 - change the transparency of copper laying
[trio basic from introduction to mastery tutorial 20] trio calculates the arc center and radius through three points of spatial arc
Compilation warning solution sorting in Quartus II
Use of orbbec Astra depth camera of OBI Zhongguang in ROS melody