资源简介
codesys PLC的共享内存方式实现变量通讯,版本为3.5,下位机程序包括C++和C#
代码片段和文件信息
#include
#include
#include
#include
#include
#include
struct DataExchange {
int i1;
int i2;
};
int main(int argc char **argv)
{
struct DataExchange *pRead *pWrite;
char sSharedMemReadName[100] = “_CODESYS_SharedMemoryTest_Write“;
char sSharedMemWriteName[100] = “_CODESYS_SharedMemoryTest_Read“;
int fdRead = shm_open(sSharedMemReadName O_CREAT | O_RDWR S_IRWXU | S_IRWXG);
printf(“Shared Memory Read: %s %d\n\n“sSharedMemReadName fdRead);
ftruncate(fdRead sizeof(*pRead));
pRead = mmap(0 sizeof(*pRead) PROT_READ | PROT_WRITE MAP_SHARED fdRead 0);
close(fdRead);
int fdWrite = shm_open(sSharedMemWriteName O_CREAT | O_RDWR S_IRWXU | S_IRWXG);
printf(“Shared Memory Write: %s %d\n\n“sSharedMemWriteName fdWrite);
ftruncate(fdWrite sizeof(*pWrite));
pWrite = mmap(0 sizeof(*pWrite) PROT_READ | PROT_WRITE MAP_SHARED fdWrite 0);
close(fdWrite);
do
{
sleep(1);
printf(“pRead->i1: %d pRead->i2: %d pWrite->i1: %d pWrite->i2: %d\n“
pRead->i1 pRead->i2 pWrite->i1 pWrite->i2);
printf(“Press ‘Enter‘ to increment values or ‘q‘ and then ‘Enter‘ to quit\n“);
pWrite->i1++;
pWrite->i2--;
} while (getchar() != ‘q‘);
munmap(pRead sizeof(*pRead));
shm_unlink(sSharedMemReadName);
munmap(pWrite sizeof(*pWrite));
shm_unlink(sSharedMemWriteName);
exit(0);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 256 2016-05-25 14:57 origin.xm
文件 14678 2016-07-06 10:50 package.manifest
文件 74870 2016-05-25 15:05 \Component\DeviceDesc
文件 310852 2016-05-25 15:05 \Component\Library\_3sstorage.compiled-library-ge33
文件 52071 2016-05-25 15:05 \Component\Library 10\caa_fbfactory.compiled-library-ge33
文件 74148 2016-05-25 15:05 \Component\Library 11\caa_memblockman_extern.compiled-library-ge33
文件 399608 2016-05-25 15:05 \Component\Library 12\caa_resman_extern.compiled-library-ge33
文件 566851 2016-05-25 15:05 \Component\Library 13\caa_storage.compiled-library-ge33
文件 16061 2016-05-25 15:05 \Component\Library 14\caa_tick_extern.compiled-library-ge33
文件 17201 2016-05-25 15:05 \Component\Library 15\caa_tickutil_extern.compiled-library-ge33
文件 314416 2016-05-25 15:05 \Component\Library 16\caa_types_extern.compiled-library-ge33
文件 51713 2016-05-25 15:05 \Component\Library 17\cmpapp.compiled-library-ge33
文件 38648 2016-05-25 15:05 \Component\Library 18\cmpbintagutiliec.compiled-library-ge33
文件 19572 2016-05-25 15:05 \Component\Library 19\cmpbitmappool.compiled-library-ge33
文件 68330 2016-05-25 15:05 \Component\Library 2\3slicense.compiled-library-ge33
文件 25327 2016-05-25 15:05 \Component\Library 20\cmpchannelclientiec.compiled-library-ge33
文件 18839 2016-05-25 15:05 \Component\Library 21\cmpcodemeter.compiled-library-ge33
文件 21064 2016-05-25 15:05 \Component\Library 22\cmpdynamictext.compiled-library-ge33
文件 12708 2016-05-25 15:05 \Component\Library 23\cmperrors2_itfs.compiled-library-ge33
文件 27479 2016-05-25 15:05 \Component\Library 24\cmpeventmgr.compiled-library-ge33
文件 17125 2016-05-25 15:05 \Component\Library 25\cmplog.compiled-library-ge33
文件 18227 2016-05-25 15:05 \Component\Library 26\cmpschedule.compiled-library-ge33
文件 13841 2016-05-25 15:05 \Component\Library 27\cmpsrv.compiled-library-ge33
文件 12556 2016-05-25 15:05 \Component\Library 28\cmptargetvisu.compiled-library-ge33
文件 142646 2016-05-25 15:05 \Component\Library 29\cmptracemgr.compiled-library-ge33
文件 60940 2016-05-25 15:05 \Component\Library 3\alarmmanager_itfs.compiled-library-ge33
文件 33575 2016-05-25 15:05 \Component\Library 30\cmpvisuhandler.compiled-library-ge33
文件 21360 2016-05-25 15:05 \Component\Library 31\collections_itfs.compiled-library-ge33
文件 161326 2016-05-25 15:05 \Component\Library 32\collections.compiled-library-ge33
文件 40088 2016-05-25 15:05 \Component\Library 33\cm.compiled-library-ge33
文件 76219 2016-05-25 15:05 \Component\Library 34\dataserver_itfs.compiled-library-ge33
............此处省略81个文件信息
相关资源
- vc6.0串口通信,采用mscomm控件
- vs2013串口程序
- VS2010基于对话框的MFC串口通信简明例
- VS2017-MFC串口通信(基于CSerialPort类)
- VS2013写的MFC多线程多串口编程,多串
- CodeSys最好的中文教程
- 利用mfc实现的udp通信,包括,客户端
- MFC CSerialPort类串口通信
- 无线通信系统仿真--C++实用模型包含源
- C++ 基于蓝牙的通信 代码
- Visual C++/Turbo C串口通信编程实践第2版
- 基于VC++ Socket 网络调试助手源码
- 用vs2010编写基于MFC的串口通信程序
- 三菱MX Component软件和操作手册和编程
- 基于UDP的聊天程序MFC实现
- c++ Windows Socket实现最简单的C/S网络通
- VC++ USB及串口通信工程源码
- Visual C#.NET串口通信及测控应用典型
- 基于winusb的上位机与USB的通信
- stm32 上下位机通信
- C/C++串口通信典型应用编程实践.(配
- MFC socket与websocket通信
- visual c++串口通信技术详解
- 单片机与PC机串口通信的类程序
- c++ 串口通信Demo源码(方便学习调试)
- 串口通信上位机开发(c++代码)
- uip 通信(stm32) 源代码
- MFC做的wifi通信上位机
- plc复习资料.doc(复习提纲)
- 基于MFC的TCP通信服务器端
评论
共有 条评论