ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:19.64KB ,
资源ID:19122656      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/19122656.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(分析BACnet协议栈1Word格式.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

分析BACnet协议栈1Word格式.docx

1、 */* Use ionice wrapper to improve serial performance: $ sudo ionice -c 1 -n 0 ./bin/bacserv 12345*/* handle returned from open() */static int RS485_Handle = -1;/* baudrate settings are defined in , which is included by RS485 from B&B Electronics USOPTL4 */static char *RS485_Port_Name = /dev/ttyUSB0

2、;/*系统默认是通过USB转485的,根据需要设置,若你的开发板用485接口,则用static char *RS485_Port_Name = /dev/ttyS0代替 */* some terminal I/O have RS-485 specific functionality */#ifndef RS485MOD#define RS485MOD 0#endif/* serial I/O settings */static struct termios RS485_oldtio;/* Ring buffer for incoming bytes, in order to speed up

3、the receiving. */static FIFO_BUFFER Rx_FIFO;/* buffer size needs to be a power of 2 */static uint8_t Rx_Buffer4096;#define _POSIX_SOURCE 1 /* POSIX compliant source */* DESCRIPTION: Configures the interface name* RETURN: none* ALGORITHM:* NOTES:*/void RS485_Set_Interface( char *ifname) /* note: expe

4、cts a constant char, or char from the heap */ if (ifname) RS485_Port_Name = ifname; Returns the interface nameconst char *RS485_Interface( void) return RS485_Port_Name;/* Returns the baud rate that we are currently running at*/uint32_t RS485_Get_Baud_Rate( uint32_t baud = 0; switch (RS485_Baud) case

5、 B0: baud = 0; break; case B50: baud = 50; case B75: baud = 75; case B110: baud = 110; case B134: baud = 134; case B150: baud = 150; case B200: baud = 200; case B300: baud = 300; case B600: baud = 600; case B1200:baud = 1200; case B1800: baud = 1800; case B2400: baud = 2400; case B4800: baud = 4800;

6、 case B9600:baud = 9600; case B19200: baud = 19200; case B38400: baud = 38400; case B57600: baud = 57600; case B115200: baud = 115200; case B230400: baud = 230400; default: baud = 9600; return baud; Sets the baud rate for the chip USARTbool RS485_Set_Baud_Rate( uint32_t baud) bool valid = true; swit

7、ch (baud) case 0: RS485_Baud = B0; case 50: RS485_Baud = B50; case 75: RS485_Baud = B75; case 110: RS485_Baud = B110; case 134: RS485_Baud = B134; case 150: RS485_Baud = B150; case 200: RS485_Baud = B200;break; case 300: RS485_Baud = B300; case 600: RS485_Baud = B600; case 1200: RS485_Baud = B1200;

8、case 1800: RS485_Baud = B1800; case 2400: RS485_Baud = B2400; case 4800: RS485_Baud = B4800; case 9600: RS485_Baud = B9600; case 19200: RS485_Baud = B19200; case 38400: RS485_Baud = B38400; case 57600: RS485_Baud = B57600; case 115200: RS485_Baud = B115200; case 230400: RS485_Baud = B230400; valid =

9、 false; if (valid) /* FIXME: store the baud rate */ return valid; Transmit a frame on the wirevoid RS485_Send_Frame( volatile struct mstp_port_struct_t *mstp_port, /* port specific data */ uint8_t * buffer, /* frame to send (up to 501 bytes of data) */ uint16_t nbytes) /* number of bytes of data (up

10、 to 501) */ uint32_t turnaround_time = Tturnaround * 1000; uint32_t baud = RS485_Get_Baud_Rate(); ssize_t written = 0; int greska; /* sleeping for turnaround time is necessary to give other devices time to change from sending to receiving state. */ usleep(turnaround_time / baud);/至少要等待Tturnaround时间才

11、启动RS485缓冲器发送 /* On success, the number of bytes written are returned (zero indicates nothing was written). On error, -1 is returned, and errno set appropriately. If count is zero and the file descriptor refers to a regular file, 0 will be returned without causing any other effect. For a special file

12、, the results are not portable. written = write(RS485_Handle, buffer, nbytes);/RS485_Handle初始时是为-1,当发出open操作时应该是个正整数,而write函数的原型是(fd,buf,n) greska = errno; if (written SilenceTimerReset(); return; Get a byte of receive dataRS485_Check_UART_Data函数分别检查ReceiveError、DataAvailable。然后选择端口从UART中读数据void RS4

13、85_Check_UART_Data( volatile struct mstp_port_struct_t *mstp_port) fd_set input; struct timeval waiter; uint8_t buf2048; int n; if (mstp_port-ReceiveError = true) /* do nothing but wait for state machine to clear the error */ /* burning time, so wait a longer time */ waiter.tv_sec = 0; waiter.tv_use

14、c = 5000; else if (mstp_port-DataAvailable = false) /* wait for state machine to read from the DataRegister */ if (FIFO_Count(&Rx_FIFO) 0) /* data is available */DataRegister = FIFO_Get(&Rx_FIFO);DataAvailable = true; /* FIFO is giving data - dont wait very long */ waiter.tv_usec = 10; /* FIFO is em

15、pty - wait a longer time */ /* grab bytes and stuff them into the FIFO every time */ FD_ZERO(&input); FD_SET(RS485_Handle, & n = select(RS485_Handle + 1, &input, NULL, NULL, &waiter); if (n if (FD_ISSET(RS485_Handle, &input) n = read(RS485_Handle, buf, sizeof(buf); FIFO_Add(&Rx_FIFO, &buf0, n);void

16、RS485_Cleanup( /* restore the old port settings */ tcsetattr(RS485_Handle, TCSANOW, &RS485_oldtio);/tcgetattr用于获取终端的相关参数,而tcsetattr函数用于设置终端参数 close(RS485_Handle);void RS485_Initialize( struct termios newtio;RS485: Initializing %s, RS485_Port_Name); Open device for reading and writing. Blocking mode - more CPU ef

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1