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

📄 diag_os.h

📁 Freediag contains various drivers (ISO9141, ISO14230, SAEJ1850-VPW, SAEJ1850-PWM) for different adap
💻 H
字号:
/*
 *	freediag - Vehicle Diagnostic Utility
 *
 * CVSID $Id: diag_os.h,v 1.2 2002/04/30 18:47:22 rpalmeida Exp $
 *
 * Copyright (C) 2001 Richard Almeida & Ibex Ltd (rpa@ibex.co.uk)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 *************************************************************************
 */

#ifndef _DIAG_OS_H_
#define _DIAG_OS_H_

#ifdef WIN32
/* ... windows stuff */

	#include <windows.h>	
	#include <iostream.h>
	#include <time.h>
//	#include <winsock.h> /* for timeval */
	#include <shlwapi.h> /* for StrCmp()... needs IE4 and above need v4.71 use DllGetVersion() */
	#define strcasecmp StrCmp

	typedef int ssize_t;
	typedef unsigned char u_int8_t;
	typedef unsigned short u_int16_t;
	typedef unsigned int u_int32_t;

/* struct timeval */
/* {
/* 	long    tv_sec;         seconds */
/* 	long    tv_usec;        microseconds */
/* }; */

struct timezone
{
	int     tz_minuteswest; /* minutes W of Greenwich */
	int     tz_dsttime;     /* type of dst correction */
};


/*void gettimeofday(struct timeval* tv, struct timezone* tz);*/
int gettimeofday(struct timeval* tv, struct timezone* tz)
{ /* This is not defined under Windows */
/* Note: Linux does not use the timezone struct */
	tv->tv_sec = 0;
	tv->tv_usec = 0;
	tz->tz_minuteswest = 0;
	tz->tz_dsttime = 0;
	return (0);
};

/* suspend execution for interval of seconds */
unsigned int sleep(unsigned int  seconds )
{ /* This is not defined under Windows */
	return (0);
}

/* suspend execution for interval of microseconds */
void usleep(unsigned long  usec )
{ /* This is not defined under Windows */

}

/* alarm arranges for a SIGALRM signal to be delivered
// to the process in seconds seconds.
// If seconds is zero, no new alarm is scheduled. 
// In any event any previously set alarm is cancelled. */
unsigned int alarm(unsigned int  seconds )
{ /* This is not defined under Windows */
	return (0);
}

/*
 * Structure for holding serial state for diag_os_tty_() routines
 */
typedef struct
{
	int temp;
} diag_ttystate_t;

#endif /* WIN32 */

/*
*************************************************************************
* Linux defines
*************************************************************************
*/

#ifdef LINUX
/* .. linux stuff */
	#include <unistd.h>
	#include <termios.h>
	#include <sys/ioctl.h>
	#include <sys/time.h>
	#include <linux/serial.h>
	#include <sched.h>

/*
 * Structure for holding serial state for diag_os_tty_() routines
 */
typedef struct
{
	/* For recording state before we mess with the interface */
	struct serial_struct dt_osinfo;
	struct termios dt_otinfo;
	int dt_modemflags;

	/* For recording state after/as we mess with the interface */
	struct serial_struct dt_sinfo;
	struct termios dt_tinfo;
} diag_ttystate_t;


#endif /* LINUX */

#include <sys/types.h>

/* Common prototypes but note that the source
// is different and defined in OS specific
// c files.
*/
int diag_os_millialarm(int ms);
void diag_os_sigalrm();
int diag_os_init();
int diag_os_millisleep(int ms);
ssize_t diag_os_read(int fd, void *buf, size_t count, int timeout);



/* Record current tty state */
int diag_os_tty_init(int fd, diag_ttystate_t *dt);
/* Restore ttystate before leaving */
int diag_os_tty_restore(int fd, diag_ttystate_t *dt);
/* Set speed/parity etc */
int diag_os_tty_setup(int fd, diag_ttystate_t *dt, int speed, int bits,
		int stop_bits, int parflag );
int diag_os_tty_control(int fd, diag_ttystate_t *dt, int dtr, int rts);

#endif /*_DIAG_OS_H_ */

⌨️ 快捷键说明

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