LinuxϽø³Ì¼äͨÐÅ»úÖÆ£ºFIFO£¨ÃüÃû¹ÜµÀ£©
FIFO
£¬ÓÖ³ÆÃüÃû¹ÜµÀ
£¬ÊÇLinuxÏ£¨unix»·¾³Ï£©Ò»ÖÖ½ø³Ì¼äͨÐŵĻúÖÆ£¬Ó¦Óù㷺¡£
º¯Êýmkfifo
ÓÃÓÚ´´½¨ÃüÃû¹ÜµÀ£¬Ê¹ÓÃÃüÁîman 3 mkfifo
¿É²é¿´´Ëº¯ÊýÐÅÏ¢¡£
FIFO´´½¨ºó£¬¿ÉÒÔÏñÆÕͨÎļþÒ»Ñù¶ÔÆä·ÃÎÊ¡£
LinuxÏÂÒ»¸öͬÃûÃüÁîmkfifo
Ò²ÓÃÓÚ´´½¨FIFO£¬ÀýÈ磺
Ö´ÐÐÃüÁî
$ mkfifo /tmp/fifo
$ cat /tmp/fifo
³ÌÐò×èÈû¡£
ÔÙ´ò¿ªÒ»¸öshell£¬Ö´ÐÐ
$ echo hello > /tmp/fifo
Ç°Ò»¸ö³ÌÐò·µ»Ø£¬ÏÔʾhello
ÏÂÃæÓÃÒ»¸ö¼òµ¥³ÌÐò£¬ÑÝʾFIFO IPCµÄÓ÷¨¡£
ÏÂÔصØÖ·£ºhttp://download.csdn.net/source/2378181
¸Ã³ÌÐò·ÖΪ£²¶Ë£º
server³ÌÐò´´½¨Ò»¸öFIFO£¬²¢´ÓFIFO¶ÁÈ¡×Ö·û£¬×ª»»³É´óдºóÊä³öµ½ÆÁÄ»¡£
client³ÌÐò¶ÁÈ¡Óû§ÊäÈ벢дÈëFIFO¡£
common.h
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define FIFO_PATH "/tmp/myfifo"
server.c
/*
*½«´ÓFIFOÊÕµ½µ½Êý¾Ý£¨×Ö·û£©×ª»»Îª´óд£¬²¢Êä³öµ½ÆÁÄ»
*/
#include "common.h"
int main()
{
int ret;
int fd;
char buffer;
int nread;
int i;
/*½¨Á¢FIFO*/
ret = mkfifo(FIFO_PATH, 0777);
/*´ò¿ªFIFO*/
fd = open(FIFO_PATH, O_RDONLY);
if(-1 == fd)
{
printf("error\n");
return -1;
}
while(1)
{
nread = read(fd, &buffer, 1);
if(nread > 0)
{
buffer = toupper(buffer);
printf("%c", buffer);
}
}
}
ÔËÐÐserverºó£¬¿É¿´µ½´´½¨ÁËÎļþ/tmp/myfifo£¬ÕâÊÇmkfifoº¯ÊýÖ¸¶¨µÄÃüÃû¹ÜµÀµÄ·¾¶£¨Ãû×Ö£©¡£
µ±È»£¬ÏµÍ³²»»áÕæµÄÔÚ´ÅÅÌÉÏ´´½¨Õâ¸öÎļþ¡£
client.c
/*
*¶ÁÈ¡ÊäÈ룬²¢Ð´ÈëFIFO
*/
#include "common.h"
int main()
{
int fd;
int ret;
char c;
fd = open(FIFO_PATH, O_WRONLY);
if(-1 == fd)
{
printf("error\n");
return -1;
}
while(c = getchar())
{
write(fd, &c, 1);
}
}
ÏÈÆô¶¯server³ÌÐò£¬ÔÙÔËÐÐclient£¬Ëæ±ãÊäÈëЩ×Ö·û¡£
server¶Ë½«ÔÚÆÁÄ»ÉÏÏÔʾת»»Îª´óдºóµÄÊäÈë×Ö·û¡£
×÷ÕߣºZhengZhiren
ÔÎÄÁ´½Ó£ºhttp://blog.csdn.net/ZhengZhiRen/archive/2010/05/21/5613843.aspx
Ïà¹ØÎĵµ£º
1.Windows Ï´ò¿ªvirtualBox £¬Æô¶¯ÐéÄâ»ú¡£ÔÚÐéÄâ»ú´°¿ÚÉÏÑ¡Ôñ É豸 ->·ÖÅäÊý¾Ý¿Õ¼ä
2.Ñ¡ÔñWindowsÏÂÄãÏëÒª¹²ÏíµÄÎļþ¼Ð ÈçH:share , Ìí¼Ó¹Ì¶¨Êý¾Ý·ÖÅä¿Õ¼ä ,·ÖÅä¸÷Ãû×ÖÈ磺VMshare
3.ÔÚÐéÄâ»úlinuxÖն˹ÒÆð¸Õ·ÖÅäµÄÊý¾Ý¿Õ¼ä£¬
sudo monut -t vboxsf VMshare /home/plus/share #ÆäÖÐ/home/plus/shareÊÇ ......
Ò»¡¢ÒýÑÔ£º
±¾ÎĵµµÄÄÚÈݴ󲿷ÝÄÚÈݶ¼ÊÇ´ÓÍøÉÏÊÕ¼¯¶øÀ´£¬È»ºóÅäºÏһЩеĽØͼ£¨Äں˰汾£ºV2.4.19£©¡£ÔÚÿһÅäÖÃÏîºó»áÓÐÒ»¸öÑ¡ÔñÖ¸ÄϵIJ¿·Ý£¬ÓÃÀ´Ö¸µ¼´ó¼ÒÔõôÑù¸ù¾Ý×Ô¼ºµÄÇé¿öÀ´×öÏàÓ¦µÄÑ¡Ôñ£»»¹ÓÐÔÚÿһ¸ö´óÏîºÍÎĵµµÄ×îºó»áÓÐÒ»¸ö¾Ñé̸£¬ËüÊÇһЩ¸ßÊÖÃÇÔÚÓ¦¶ÔÎÊÌâºÍ´¦ÀíÌØÓÐÓ²¼þʱµÄһЩ¾Ñ飨Õâ¸ö»¹µ ......
ÓÉÓÚÎÒÔÚÍøÉÏÏÂÔØÁËUbuntu LinuxÀ´°²×°·¢ÏÖÊÖͷû¿Õ°×¹âÅ̼̿cd,ËùÓÐgoogleÁËÏÂÕÒµ½ÁËÈçÏÂÎÄÕ½øÐÐʵ¼ù. ===================½Ì³Ì1========================== ˵µ½°²×°²Ù×÷ϵͳ£¬´ó¶àÊýÈËÊìϤµÄÊÇ´Ó¹âÅÌÒýµ¼£¬Æäʵ´ÓºÜ¶à´æ´¢É豸¶¼¿ÉÒÔʵÏÖϵͳÒýµ¼µÄ¡£ÓÉÓÚLinux²Ù×÷ϵͳµÄ·¢²¼ºÜ¶à£¬¶ø¶àÊýÈ˶¼ÊÇͨ¹ýÍøÂçÏÂÔزÙ×÷ϵͳµ ......
ÔÚÇ°ÃæµÄÎÄÕÂÖÐÌá¼°µ½£¬Ò»¸ö½ø³ÌÖеĶà¸öÏß³ÌÊǹ²Ïíͬһ¶Î×ÊÔ´µÄ£¬ÓÉÓÚÏ̶߳Ô×ÊÔ´µÄ¾ºÕùÒý³öÁËËø¡£ÆäÖÐmutexÊÇÒ»ÖÖ¼òµ¥µÄ¼ÓËø·½·¨£¬Õâ¸ö»¥³âËøÖ»ÓÐÁ½ÖÖ״̬£¬ÄǾÍÊÇÉÏËøºÍ½âËø£¬¿ÉÒÔ°Ñ»¥³âËø¿´×÷ÊÇijÖÖÒâÒåÉϵÄÈ«¾Ö±äÁ¿¡£ÔÚijһʱ¿Ì£¬Ö»ÄÜÓÐÒ»¸öÏß³ÌÈ¡µÃÕâ¸ö»¥³âÉϵÄËø£¬ÓµÓÐÉÏËø״̬µÄÏ߳̿ÉÒÔ¶Ô¹²Ïí×ÊÔ´½øÐвÙ×÷£¬¶øÆäË ......
Linux ²Ù×÷ϵͳ´ÓÒ»¿ªÊ¼¾Í¶Ô´®ÐпÚÌṩÁ˺ܺõÄÖ§³Ö£¬±¾ÎÄ¾Í Linux ϵĴ®ÐпÚͨѶ±à³Ì½øÐмòµ¥µÄ½éÉÜ¡£ ´®¿Ú¼ò½é ´®ÐпÚÊǼÆËã»úÒ»ÖÖ³£ÓõĽӿڣ¬¾ßÓÐÁ¬½ÓÏßÉÙ£¬Í¨Ñ¶¼òµ¥£¬µÃµ½¹ã·ºµÄʹÓᣳ£ÓõĴ®¿ÚÊÇ RS-232-C ½Ó¿Ú£¨ÓÖ³Æ EIA RS-232-C£©ËüÊÇÔÚ 1970 ÄêÓÉ ......