首页 技术 正文
技术 2022年11月23日
0 收藏 689 点赞 3,954 浏览 1147 个字

本文欢迎引用,转载。

引用,转载请标明出处!

调试完毕源码将上传到GitHub

为了嵌入式系统与STEP 7 PLC 通过S7 协议通讯,尝试移植 Snap 7 到STM32F407 cpu 上。

今天基本编译通过,尚未通电调试。

核心技术要点,及方案如下

1。测试系统构建(待续)

在LwIP 协议栈移植 Snap 7

2。代码修改

A.修改文件snap_msgsock.cpp 开始部分,为以下内容

#include <stdint.h>
#include "lwip/sockets.h"
#include "snap_msgsock.h"
#include <string.h>

B.修改文件snap_sysutils.cpp为以下内容,重点是对 timeGetTime() 的支持

#include "snap_sysutils.h"
#include "stm32f4xx_hal.h"
#ifdef OS_OSX
int clock_gettime(int clk_id, struct timespec* t)
{
struct timeval now;
int rv = gettimeofday(&now, NULL);
if (rv) return rv;
t->tv_sec = now.tv_sec;
t->tv_nsec = now.tv_usec * ;
return ;
}
#endif//---------------------------------------------------------------------------
longword SysGetTick()
{
#ifdef OS_WINDOWS
return timeGetTime();
#else
#ifdef STM32F407xx
return HAL_GetTick();
#else
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (longword) (ts.tv_sec * ) + (ts.tv_nsec / );
#endif
#endif
}
//---------------------------------------------------------------------------
void SysSleep(longword Delay_ms)
{
#ifdef OS_WINDOWS
Sleep(Delay_ms);
#else
#ifdef STM32F407xx
HAL_Delay(Delay_ms);
#else
struct timespec ts;
ts.tv_sec = (time_t)(Delay_ms / );
ts.tv_nsec =(long)((Delay_ms - ts.tv_sec) * );
nanosleep(&ts, (struct timespec *));
#endif
#endif
}

编译选项设置

在LwIP 协议栈移植 Snap 7

未完,待续

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,994
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,507
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,350
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,135
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,768
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,845