Linux电脑通过RS-232向PLC发送rs232信号波形。 我在装有linux系统的电脑上写了个C++程序

广州正嘉电脑维修培训基地
广州嵌入式linux系统与应用开发就业班
: 随到随学
: 广州市科学城光谱西路69号TCL文化产业园4层
嵌入式linux系统与应用开发就业班
参加嵌入式linux系统与应用开发就业班可以使学员快速掌握嵌入式系统开发的流程,系统移植的方法,编写Bootloader等。学习本课程的学员能够从事嵌入式系统相关的项目开发。
1、培训过程中,如有部分内容理解不透或消化不好,可免费在下期培训班中重听;
2、培训结束后免费提供一个月的技术支持,充分保证培训后出效果;
3、广嵌承诺:保证就业,不就业退款
4、前十名报名送GEC2410开发套件
5、3000元现金优惠,两人同时报名,享受95折优惠;三人及三人以上同时报名,享受9折优惠,学生更优惠。
参加嵌入式linux系统与应用开发就业班可以使学员快速掌握嵌入式系统开发的流程,系统移植的方法,Bootloader的原理,可以编写自己的Bootloader。学习本课程的学员能够从事嵌入式系统相关的项
嵌入式系统开发工程师、系统移植工程师。
消费类电子、工业控制、军工企事业、电信/网络/通讯、航空航天、汽车电子、医疗设备、仪器仪表等相关行业
◆ 熟练使用Linux操作系统;
◆ 熟悉C语言编程和汇编语言编程;
◆ 对ARM处理器有一定的了解。
GCSDE认证 ARM-ATC认证
黄松青 唐辉
详细课程介绍
嵌入式linux 系统与应用开发就业班课程大纲
1周入学辅导+14周理论+2周项目指导(其中含7周项目实践)
入学考核:
C语言基础、C++基础、数据结构、操作系统原理、Linux应用基础、电子电路基础
开课前一周:入学基础测试与辅导(C语言、C++、linux基础、数据结构、电子电路)
Linux 快速入门
Linux 概述; Linux发行版;
Linux开发环境搭建-vmware虚拟机;Linux系统安装
Linux的基础知识; Linux文件系统和文件; Shell的使用;
常用的shell命令;Linux的软件安装;
Linux 下的C语言编程基础;Linux下VIM的使用;
编译器GCC的使用;调试器gdb的使用;
Linux下多文件编译与项目管理工具make的使用;
C语言基础强化
C语言的内存布局与常见库函数
数据结构基础强化
链表、队列、栈、树、哈希表
数据搜索、遍历、排序与常见算法
C++语言基础强化
面向对象的编程方法 类及对象的封装 类的继承与派生
虚函数与多态性 构造函数与虚构函数 模板 异常处理
ARM硬件接口
嵌入式微处理器 ARM寄存器 ARM工作模式
ARM异常中断 ARM汇编指令分类 ARM汇编指令寻址方式
ARM汇编程序设计 C及汇编语言混合编程
基本ARM汇编指令编程;数据访问练习;
ARM汇编和C混合编程;ARM指令和THUMB指令混合编程
MDK开发环境使用 U-Linuk仿真器使用
ARM开发调试环境建立 ARM GPIO应用
ARM存储器控制器 ARM中断控制器(IRQ和FIQ)
ARM汇编语言与C语言实现跑马灯;
IRQ与FIQ中断流程分析
ARM时钟及定时器;TFT LCD驱动程序设计
看门狗定时器应用;LCD显示曲线及图片;
LCD汉字显示实验;
ADC控制器应用;触摸屏应用及校准
ADC应用实验;触摸屏实现实验
PWM时钟应用;实时时钟及闹钟应用
蜂鸣器控制;实时时钟及闹钟应用;
ARM工作模式转换;ARM启动代码设计
NOR Flash应用设计;NAND Flash应用设计
IIC总线控制器
NOR Flash编程;NAND Flash编程;
交叉开发环境搭建
嵌入式系统定义;Linux交叉开发环境介绍;
GNU交叉工具链的使用;宿主机与PC机间的通信;
串口通信;交叉调试;
Minicom配置使用,Windows超级终端配置实验;
NFS共享设置实验
Linux下C语言开发
文件I/O操作编程;
Linux系统调用与用户编程接口;
Linux中文件及文件描述符概述;
不带缓存的文件I/O操作;标准I/O开发。
文件操作 目录操作 特殊文件
Linux进程概述;Linux下进程结构;Linux下进程的模式类型;
Linux下进程管理;Linux进程控制编程;守护进程;
信号及信号处理
进程间通信;多线程编程
管道;管道创建与读写;标准流管道;FIFO信号量;
共享内存实现;消息队列实现
线程概述与分类;Linux线程技术发展;线程的实现和基本操作;
线程访问控制。
TCP/IP协议概述;OSI参考模型和TCP/IP参考模型;
TCP/IP协议栈;TCP和UDP;
套接字基础 网络Socket概述;Socket通信原理;
Socket基础编程。
套接字编程进阶 多路选择I/O 文件传输实现
嵌入式GUI设计
Linux下嵌入式gui编程介绍;Qt介绍;通过Qt designer认识Qt; 信号和槽;Qt的事件
QT中的多线程编程;Qt 中的网络编程。
Qt界面布局与特效处理
嵌入式数据库应用
数据库基础
嵌入式数据库应用
嵌入式GUI与数据库结合技术
根文件系统
常见根文件系统一(cramfs、jffs2)
根文件系统的目录结构;根文件系统内容;
常见根文件系统制作;添加设备文件;添加动态链接库;
添加系统应用程序;添加配置文件;
常见根文件系统二(yaffs、romfs)
根文件系统的目录结构;根文件系统内容;
常见根文件系统制作;添加设备文件;添加动态链接库;
添加系统应用程序;添加配置文件;
综合项目架构分析与项目开发技巧
Bootloader
Bootloader介绍;GEC2440Bootloader分析;
常见bootloader源码分析;
u-boot配置与编译;u-boot移植;u-boot 使用
修改u-boot源代码,移植到开发板上
Linux内核高级技术
Linux内核结构 配置与编译移植 Linux内核模块设计
内核内存管理、进程管理、中断管理、设备管理
内核时钟和定时器管理、信号、调度
Linux内核调试与优化
Linux驱动高级应用
驱动的中断 延时 并发控制
设备驱动的阻塞与非阻塞、异步通信
高级字符设备
块设备驱动 Flash设备驱动
网络设备驱动
USB设备驱动
LCD&触摸屏 设备驱动
IIC & SPI设备驱动
设备驱动调试与移植技巧
项目指导(2周)
广州正嘉电脑维修培训基地网址 :
广州正嘉电脑维修培训基地开设的其他课程
粤嵌创立于2005年,是全球性规模经营的IT技术产品研发及教育服务机构,目前粤嵌已拥有IT技术培训、教学仪器、数字医疗系统、动漫游戏机产品四大品牌产业。公司经过多年的发展,秉承“行业引领,齐商共赢,开拓创新,服务诚信”的核心经营理念,为业界提供全面的IT技术服务和产品,在发展过程中,粤嵌形成了在IT技术自主创新方面的优势和能力,已成为在国内外IT技术领域的知名企业。
目前,粤嵌拥有员工300余名,技术人员占总人数的70%。其中自主研发的开发设备90款,国际先进水平的开发软件、仪器、设备50多类。粤嵌相继与300家国际著名IT公司建立了战略合作伙伴关系,并创建有58个联合实验室。
未来十年粤嵌将继续构建设计力、品质力及营销力为一体的系统,将粤嵌打造成国内较具影响力的IT品牌。
需要更多广州本地的培训信息?去逛逛!
您浏览过的课程
100,000+门课程
70,000+条资讯
10,000+位名师RS-232 for Linux and Windows
RS-232 for Linux, FreeBSD and windows
Here you can find code to use the serial port.
It has been tested with GCC on Linux and
on Windows.
Handshaking or flowcontrol is not supported.
It uses polling to receive characters from the serial port.
Interrupt/event-based is not supported.
It is licensed under the .
No serial port available on your computer? Use a .
This is free software, it is experimental and available under the GPL License version 3.
Despite this software is intend to be usefull, there is no warranty, use this software at your own risk.
December 19, 2015 new version:
- added the functions: RS232_flushRX(), RS232_flushTX() and RS232_flushRXTX().
October 11, 2015 new version:
- Check if the serial port is already opened by another process, before trying to open it.
January 10, 2015 new version:
- Fixed a bug that affected the parity settings.
December 6, 2014 new version:
- Make it compile on FreeBSD.
- Added the devices "/dev/cuau0", etc. needed for FreeBSD.
October 5, 2014 new version:
- Added the possibility to set the mode (databits, parity and stopbits).
- Changed function RS232_OpenComport(), from now on, an extra argument is required to set the mode.
- Fixed a bug that could set wrong baudrates on Linux systems (POSIX instead of BSD style).
Januari 31, 2014 new version:
- Fixed a bug that made it impossible to read from the serial port on Linux 64-bit systems.
December 26, 2013 new version:
- added the function RS232_IsDCDEnabled()
February 1, 2013 new version:
- added the prefix "RS232_" to all functions in order to prevent clashes with other libraries
- set the DTR pin and RTS pin active when opening a serial port (some RS-422/485 converters need this to enable the outputbuffers)
- added the baudrates 500000 and 1000000 for windows, this can be usefull when using an FTDI-chip or USB-converter
- added the devices "/dev/ttyAMA0" and "/dev/ttyAMA1" for use with the Raspberry Pi
- added the devices "/dev/ttyACM0" and "/dev/ttyACM1" for use with the Atmel (USB-)microcontrollers
- added the devices "/dev/rfcomm0" and "/dev/rfcomm1" for use with Bluetooth
- added the devices "/dev/ircomm0" and "/dev/ircomm1" for Infrared communication
- added the following functions: RS232_enableDTR(), RS232_disableDTR(), RS232_enableRTS(), RS232_disableRTS() and RS232_IsDSREnabled()
- changed function "cprintf()" to "RS232_cputs()"
The sourcecode
Extract the file and copy rs232.h and rs232.c into your project directory.
Include rs232.h in your program sourcecode (like: #include "rs232.h") and compile and link rs232.c (add rs232.c to your project).
RS232_OpenComport( comport_number,
&&Opens the comport, comportnumber starts with 0 (see the list of numbers).
&&Baudrate is expressed in baud per second i.e 115200 (see the list of possible baudrates).
&&Mode is a string in the form of &8N1&, &7E2&, etc.
&&8N1 means eight databits, no parity, one stopbit. If in doubt, use 8N1 (see the list of possible modes).
&&Returns 1 in case of an error.
RS232_PollComport( comport_number,
&&Gets characters from the serial port (if any). Buf is a pointer to a buffer
&&and size the size of the buffer in bytes.
&&Returns the amount of received characters into the buffer.
&&After succesfully opening the COM-port, connect this function to a timer.
&&The timer should have an interval of approx. 100 milliSeconds.
&&Do not forget to stop the timer before closing the COM-port.
RS232_SendByte( comport_number,
&&Sends a byte via the serial port. Returns 1 in case of an error.
RS232_SendBuf( comport_number,
&&Sends multiple bytes via the serial port. Buf is a pointer to a buffer
&&and size the size of the buffer in bytes.
&&Returns -1 in case of an error, otherwise it returns the amount of bytes sent.
&&This function blocks (it returns after all the bytes have been processed).
RS232_CloseComport( comport_number)
&&Closes the serial port.
RS232_cputs( comport_number,
&&Sends a string via the serial port. String must be null-terminated.
The following functions are normally not needed but can be used to set or check the status of the control-lines:
RS232_enableDTR( comport_number)
&&Sets the DTR line high (active state).
RS232_disableDTR( comport_number)
&&Sets the DTR line low (non active state).
RS232_enableRTS( comport_number)
&&Sets the RTS line high (active state).
RS232_disableRTS( comport_number)
&&Sets the RTS line low (non active state).
RS232_IsDSREnabled( comport_number)
&&Checks the status of the DSR-pin. Returns 1 when the the DSR line is high (active state), otherwise 0.
RS232_IsCTSEnabled( comport_number)
&&Checks the status of the CTS-pin. Returns 1 when the the CTS line is high (active state), otherwise 0.
RS232_IsDCDEnabled( comport_number)
&&Checks the status of the DCD-pin. Returns 1 when the the DCD line is high (active state), otherwise 0.
The following functions are normally not needed but can be used to empty the rx/tx buffers:
("discards data written to the serial port but not transmitted, or data received but not read")
RS232_flushRX( comport_number)
&&Flushes data received but not read.
RS232_flushTX( comport_number)
&&Flushes data written but not transmitted.
RS232_flushRXTX( comport_number)
&&Flushes both data received but not read, and data written but not transmitted.
You don't need to call RS232_PollComport() when you only want to send characters.
Sending and receiving do not influence eachother.
The os (kernel) has an internal buffer of 4096 bytes.
If this buffer is full and a new character arrives on the serial port,
the oldest character in the buffer will be overwritten and thus will be lost.
After a successfull call to RS232_OpenComport(), the os will start to buffer incoming characters.
Do not use microsoft tools to compile this library.
The microsoft C-compiler is an old and retarded compiler that does not even support ANSI C99.
Example code that demonstrates how to use the library to receive characters and print them to the screen:
/**************************************************
file: demo_rx.c
purpose: simple demo that receives characters from
the serial port and print them on the screen,
exit the program by pressing Ctrl-C
compile with the command: gcc demo_rx.c rs232.c -Wall -Wextra -o2 -o test_rx
**************************************************/
#include &stdlib.h&
#include &stdio.h&
#ifdef _WIN32
#include &Windows.h&
#include &unistd.h&
#include &rs232.h&
int main()
cport_nr=0,
/* /dev/ttyS0 (COM1 on windows) */
bdrate=9600;
/* 9600 baud */
unsigned char buf[4096];
char mode[]={'8','N','1',0};
if(RS232_OpenComport(cport_nr, bdrate, mode))
printf(&Can not open comport\n&);
return(0);
n = RS232_PollComport(cport_nr, buf, 4095);
buf[n] = 0;
/* always put a &null& at the end of a string! */
for(i=0; i & i++)
if(buf[i] & 32)
/* replace unreadable control-codes by dots */
buf[i] = '.';
printf(&received %i bytes: %s\n&, n, (char *)buf);
#ifdef _WIN32
Sleep(100);
usleep(100000);
/* sleep for 100 milliSeconds */
return(0);
Example code that demonstrates how to use the library to transmit characters and print them to the screen:
/**************************************************
file: demo_tx.c
purpose: simple demo that transmits characters to
the serial port and print them on the screen,
exit the program by pressing Ctrl-C
compile with the command: gcc demo_tx.c rs232.c -Wall -Wextra -o2 -o test_tx
**************************************************/
#include &stdlib.h&
#include &stdio.h&
#ifdef _WIN32
#include &Windows.h&
#include &unistd.h&
#include &rs232.h&
int main()
cport_nr=0,
/* /dev/ttyS0 (COM1 on windows) */
bdrate=9600;
/* 9600 baud */
char mode[]={'8','N','1',0},
str[2][512];
strcpy(str[0], &The quick brown fox jumped over the lazy grey dog.\n&);
strcpy(str[1], &Happy serial programming!.\n&);
if(RS232_OpenComport(cport_nr, bdrate, mode))
printf(&Can not open comport\n&);
return(0);
RS232_cputs(cport_nr, str[i]);
printf(&sent: %s\n&, str[i]);
#ifdef _WIN32
Sleep(1000);
usleep(1000000);
/* sleep for 1 Second */
return(0);
tip: To get access to the serial port on Linux, you need to be a member of the group &dialout&.
&&&&&&&Look
&&&&&&&Look
List of comport numbers, possible baudrates and modes:
Note: Traditional (on-board) UART's usually have a speed limit of max. 115200 baud.
&&&&&&&&&&&&Special cards and USB to Serial converters can usually be set to higher baudrates.
Connector pinlayout
When using this code, you only need to connect pins 2, 3 and 5 of the serial port (plus the shielding) to your device.PLC与PC机的串行通信在铁路信号管理中的应用,单片机与pc机通信,单片机与pc机wif..
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
PLC与PC机的串行通信在铁路信号管理中的应用
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口

我要回帖

更多关于 信捷plc rs232 通讯 的文章

 

随机推荐