Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

CentOS5.4 LinuxÏÂModbus TCP IPЭÒéC++µÄÒ»¸öСÀý×Ó

///////////////////////////////////////////////////////////////////////////
/*
ReadCoilsº¯Êý£º
¶Á¼ÌµçÆ÷µÄ״̬ £¬ ³É¹¦·µ»Øture¡£
send Êý¾Ý³¤¶È=12
recv Êý¾Ý³¤¶È=10
unsigned short int addr ¶Á¼ÌµçÆ÷µÄÆðʼµØÖ·(¼ÌµçÆ÷±àºÅ-1) ¡£
×¢Ò⣺1~8¸ö¼ÌµçÆ÷£¬ÆðʼµØÖ·´Ó0¿ªÊ¼
unsigned short int len ¶ÁÈ¡¼ÌµçÆ÷µÄ¸öÊý£¬×î´ó8.
debug_state Èç¹ûΪ1 ´òÓ¡³öµ÷ʽÐÅÏ¢
ubool *paraDO ¶Á³öµÄ¼ÌµçÆ÷״̬
SOCKET s_bnc,fd_set fds,timeval tv ÊǸ¨ÖúµÄÍøÂç½Ó¿Ú²ÎÊý
*/
///////////////////////////////////////////////////////////////////////////
inline bool ReadCoils(unsigned short int addr, byte & coilstate, SOCKET_INT s_bnc)
{
cmd_len = 12;
byte cmd_code = 1; //ÃüÁî´úÂ룺01£¬¶Á¼ÌµçÆ÷
byte *cmd_string ;
byte *echo_string ;
cmd_string = new byte[cmd_len] ;
echo_string = new byte[cmd_len] ;
cmd_string[ 0] = 0 ; // modbus ЭÒ鹿¶¨±êʾ
cmd_string[ 1] = 0 ;
cmd_string[ 2] = 0 ;
cmd_string[ 3] = 0 ;
cmd_string[ 4] = 0 ; // length ¸ßλ²¿·Ö ÃüÁîµÄºóÐø×Ö½ÚÊýÁ¿
cmd_string[ 5] = 6 ; // length µÍλ²¿·Ö ÃüÁîµÄºóÐø×Ö½ÚÊýÁ¿
cmd_string[ 6] = 0 ; // Unit Identifier :identification of a remote slave connected on a serial line or on other buses.
cmd_string[ 7] = cmd_code ;
cmd_string[ 8] = (unsigned char) (addr >> 8);
cmd_string[ 9] = (unsigned char) addr;
cmd_string[10] = 0; //(unsigned char) (len >> 8);
cmd_string[11] = 8; //(unsigned char) len ;
int iret;
fd_set fds;
struct timeval tv;
tv.tv_sec = SLEEP ; //³¬Ê±µÈ´ýʱ
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(s_bnc, &fds);
/* wait for permission to send(µÈ´ýÊÇ·ñ¿Éдwrite)*/
iret = select(s_bnc +1, NULL, &fds, NULL, &tv); /*write*/
if (iret=0)
{
if(debug_state) printf("Timer over!n");
close(s_bnc);
return false ;
}
else if (iret<0)
{
if(debug_state) printf("select is err! n");
close(s_bnc);
return false ;
}
/*send дÈëÊý¾Ý */
iret = send(s_bnc, (char *)cmd_string, cmd_len , 0);
if


Ïà¹ØÎĵµ£º

C/C++ header file lists

  C/C++Í·ÎļþÒ»ÀÀ ÊÕ²Ø
C/C++Í·ÎļþÒ»ÀÀ
C¡¢´«Í³ C++
#include <assert.h>¡¡¡¡¡¡¡¡//É趨²åÈëµã
#include <ctype.h>¡¡¡¡¡¡¡¡ //×Ö·û´¦Àí
#include <errno.h>¡¡¡¡¡¡¡¡ //¶¨Òå´íÎóÂë
#include <float.h>¡¡¡¡¡¡¡¡ //¸¡µãÊý´¦Àí
#include <fstream.h>¡¡¡¡¡¡ //ÎļþÊäÈ룯Êä³ö
#i ......

LinuxÖÐÎļþ¼ÐµÄ½â¶Á

[/b][url]http://blog.chinaunix.net/u3/95713/showart_1931142.html[/url]
Linux¸ù¾Ý°æ±¾µÄ²»Í¬, ÎļþµÄ×éÖ¯½á¹¹µ±È»»áÓÐËù²î±ð,µ«Ö÷ÒªµÄÎļþ¼ÐÓ¦¸ÃÊÇÒ»ÑùµÄ,Á˽âÕâЩÎļþ¼ÐµÄº¬Òå,¶ÔÓÚÁ˽âLinuxÓÐ×ÅÖØÒªµÄÒâÒå.

1, /  LinuxÎļþϵͳµÄÈë¿Ú£¬Ò²ÊÇ´¦ÓÚ×î¸ßÒ»¼¶µÄĿ¼£»
2, /bin ϵͳËùÐèÒªµÄÄÇЩÃüÁîλÓÚ´Ë ......

linuxÏÂdbstartºÍdbshutÆô¶¯ºÍ¹Ø±ÕÊý¾Ý¿âÎÊÌâ


°æ±¾10.2
ÔÚ9iÏÂdbstart´æÔÚÒ»bug£ºdbstartÆô¶¯Ê±ÔÚ$ORACLE_HOME/dbsÏÂѰÕÒinitSID.ora£¬ÊÂʵÉÏÔÚ¸ÃĿ¼Ï²»´æÔÚÕâ¸öpfile£¬ÔÚ9i ÒѾ­Ê¹ÓÃÁËspfile£¬ËùÒÔÒªÏëÕý³£Í¨¹ýdbstartÆô¶¯db£¬ÐèÒªÔÚĿ¼$ORACLE_HOME/dbsÏ´´½¨Ò»¸öinitSID.ORAÎļþ£¬10gÖÐÎÒ·¢ÏÖÐÞÕýÁËÕâÒ»ÎÊÌâ¡£²»¹ý10gÖÐdbstartÔÚ×Ô¶¯Æô¶¯listenerʱ´æÔÚÒ»ÎÊÌ⣠......

linux ¶¯Ì¬Á´½Ó¿â¼ÓÔØ

Linux ¶¯Ì¬Á´½Ó
Linux ÖеÄÓ¦ÓóÌÐòÒÔÒÔÏÂÁ½ÖÖ·½Ê½Ö®Ò»Á´½Óµ½Íⲿº¯Êý£ºÒªÃ´ÔÚ¹¹½¨Ê±Ó뾲̬¿â£¨ lib*.a £© ¾²Ì¬µØÁ´½Ó£¬²¢ÇÒ½«¿â´úÂë°üº¬ÔÚ¸ÃÓ¦ÓóÌÐòµÄ¿ÉÖ´ÐÐÎļþÀҪôÔÚÔËÐÐʱÓë¹²Ïí¿â£¨ lib*.so £© ¶¯Ì¬µØÁ´½Ó¡£Í¨¹ý¶¯Ì¬Á´½Ó×°ÈëÆ÷£¬½«¶¯Ì¬¿âÓ³Éä½øÓ¦ÓóÌÐòµÄ¿ÉÖ´ÐÐÄÚ´æÖС£ÔÚÆô¶¯Ó¦ÓóÌÐò֮ǰ£¬¶¯Ì¬Á´½Ó×°ÈëÆ÷½«ËùÐ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ