⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readseq.c

📁 hoap2 robot access source code
💻 C
字号:
/* シ〖ケンスモ〖ドでのデ〖タ艰评のサンプルプログラム  附哼悸乖面のシ〖ケンスモ〖ド悸乖冯蔡を绵肌山绩する。*/#include <stdio.h>#include <string.h>#include <stdlib.h>#include <pthread.h>/*鼎铜メモリ脱年盗*/#include <mbuff.h>#include "MemMan.h"#define NAME_OF_MEMORY "DataSharedMemory"SM* pSM;#include "sm_access.h"void* thread_function(void* arg);int g_exit = 0;int main(int argc, char *argv[]){	pthread_t mythread;	char tmp = NULL;//	printf("program read_SM.\n");	//鼎铜メモリアロケ〖ション		pSM = (SM*) mbuff_alloc(NAME_OF_MEMORY, sizeof(SM));	if(pSM == NULL) {		perror("mbuff_alloc failed");		return -1;	}	printf("VarIF.Mode = %d\n", pSM->VarIF.Mode);	printf("read SeqDat\n");	/*シ〖ケンスモ〖ドの渴乖觉斗を斧て、悸乖窗位したデ〖タを绵肌山绩する	スレッドの侯喇*/	if(pthread_create(&mythread, NULL, thread_function, NULL)) {		perror("creating thread");		return -1;	}	/*部かキ〖を病すと姜位する*/	scanf("%c", &tmp);	g_exit = 1;	/*スレッド姜位を略つ*/	if(pthread_join(mythread, NULL)) {		perror("join thread");		return -1;	}	/*メモリ倡庶*/	mbuff_free(NAME_OF_MEMORY, (void*)pSM);		return 0;}void* thread_function(void* arg){	DUNIT* unit;	int max;	int current = 0;	current = 0;	max = pSM->Data.nSeq;	printf("pSM->Data.nSeq = %d\n", max);	/*シ〖ケンスモ〖ドのデ〖タを、姜位したところまで山绩する。*/	/*姜位していなければ略つ*/	for(;;) {		if(g_exit) return 0;		unit = (DUNIT*)&(pSM->Data.SeqDat[current]);		/*レスポンスタイムに猛が掐っていれば、そのコマンドは悸乖窗位している*/		while(unit->ResTime == 0) {			if(g_exit) return 0;			sleep(1);		}		printf("DataNo.%d\n", current);		read_sm(unit);		current++;		if(current >= max) return 0;	}		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -