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

📄 timer.c

📁 modbus rtu协议 linux 平台的实现.读取相关配置文件信息.通过串口发送数据.
💻 C
字号:
/******************************************************************************
 *
 * Copyright (c) 2008 Shanghai IS Software
 *
 * All rights reserved
 *
 * $Revision$
 *
 * $LastChangedBy$:
 * 1. lcj
 *
 * $LastChangedData$:
 * 2008/09/25
 *
 * Description: timer  ( 10ms )
 *
 * Revision History:
 * 2008/09/25 14:33 by lcj
 * #1.created
 *
 *****************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/select.h>
#include <errno.h>


void ms_sleep(unsigned long ms)
{
	int err;

	struct timeval tv;

	tv.tv_sec = ms/1000;
	tv.tv_usec = (ms%1000) * 1000;

	while ((-1 == select(0,0,0,0,&tv)) && (err == errno));
}

void timer(int sec,long usec)
{
	struct timeval tvselect;

	tvselect.tv_sec = sec;
	tvselect.tv_usec = usec;

	select(0,NULL,NULL,NULL,&tvselect);
}

⌨️ 快捷键说明

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