Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

LinuxÖ»ÊÇÒ»¸ö´«Ëµ

  ΪʲôLinux²»ÄÜÆÕ¼°£¬ÏàÐÅÕâ¸öÎÊÌâʹÓùýLinuxµÄÓû§¶àÉٵĶ¼Äܸоõµ½¡£µ±È»ÔÚÆÕ¼°Õâ·½Ãæ˵£¬ÎÒÃÇÒªÒÔ´óÖڵĹÛÄîÀ´¿´£¬ËùνµÄ´óÖÚ¾ÍÊÇÄÇЩÆÕͨµÄÓû§£¬·ÇרҵµÄÈËÊ¿¡£È«ÇòʹÓõçÄÔµÄ80%µÄÈËȺ»¹ÊÇÆÕͨÓû§£¨ÕâÀïµÄ80%ÊǸù¾ÝÈí¼þ²úÒµµÄ¹æÔòÀ´Ëµ£¬¾ßÌå¶àÉÙÎÒÒ²²»ÖªµÀ£¬O(∩_∩)O~£©£¬ÆÕͨÓû§ÐèҪʲô£¿ËûÃÇÐèÒ ......

linux ÍøÂç±à³Ì ·þÎñÆ÷Ä£ÐÍ

 Ñ§Ï°¹ý¡¶Èí¼þ¹¤³Ì¡·°É.Èí¼þ¹¤³Ì¿ÉÊÇÿһ¸ö³ÌÐòÔ±"±ØÐÞ"µÄ¿Î³Ì°¡.Èç¹ûÄãûÓÐѧϰ¹ý, ½¨ÒéÄãÈ¥¿´Ò»¿´. ÔÚÕâÒ»ÕÂÀïÃæ,ÎÒÃÇÒ»ÆðÀ´´ÓÈí¼þ¹¤³ÌµÄ½Ç¶ÈѧϰÍøÂç±à³ÌµÄ˼Ïë.ÔÚÎÒÃÇд³ÌÐò֮ǰ, ÎÒÃǶ¼Ó¦¸Ã´ÓÈí¼þ¹¤³ÌµÄ½Ç¶È¹æ»®ºÃÎÒÃǵÄÈí¼þ,ÕâÑùÎÒÃÇ¿ª·¢Èí¼þµÄЧÂʲŻá¸ß. ÔÚÍøÂç³ÌÐòÀïÃæ,Ò»°ãµÄÀ´Ëµ¶¼ÊÇÐí ......

linuxÏÂscpµÄʹÓÃ


²»Í¬µÄLinuxÖ®¼äcopyÎļþ³£ÓÃÓÐ3ÖÖ·½·¨
£¬µÚÒ»ÖÖ¾ÍÊÇftp£¬Ò²¾ÍÊÇÆäÖÐһ̨Linux°²×°ftp Server£¬ÕâÑù¿ÉÒÔÁíÍâһ̨ʹÓÃftpµÄclient³ÌÐòÀ´½øÐÐÎļþµÄcopy¡£µÚ¶þÖÖ·½·¨¾ÍÊDzÉÓÃsamba·þÎñ£¬ÀàËÆWindows
ÎļþcopyµÄ·½Ê½À´²Ù×÷£¬±È½Ï¼ò½à·½±ã£¬µÚÈýÖÖ¾ÍÊÇÀûÓÃscpÃüÁîÀ´½øÐÐÎļþ¸´ÖÆ¡£
scpÊÇÓÐSecurityµÄÎļþcopy£¬»ùÓÚsshµÇ¼ ......

LinuxÎļþ²éÕÒÃüÁîfind,xargsÏêÊö

 
À´×Ô£ºhttp://www.linuxsir.org/main/?q=node/137#1.2
ÕªÒª£º ±¾ÎÄÊÇfind ÃüÁîµÄÏêϸ˵Ã÷£¬¿É¹óµÄÊÇÕë¶Ô²ÎÊý¾ÙÁ˺ܶàµÄʵÀý£¬´óÁ¿µÄÀýÖ¤£¬ÈóõѧÕ߸üΪÈÝÒ×Àí½â£»±¾ÎÄÊÇzhyflyÐÖÌùÔÚÂÛ̳ÖУ»ÎÒ¶Ô±¾ÎĽøÐÐÁËÔÙ´ÎÕûÀí£¬Îª·½±ã´ó¼ÒÔĶÁ£»
Ŀ¼
°æȨÉùÃ÷
Ç°ÑÔ£º¹ØÓÚfindÃüÁî
Ò»¡¢find ÃüÁî¸ñʽ
1¡¢findÃüÁîµÄÒ»°ã ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ