File: eph_io.h

package info (click to toggle)
photopc 2.1-1
  • links: PTS
  • area: main
  • in suites: hamm, slink
  • size: 248 kB
  • ctags: 322
  • sloc: ansic: 3,232; makefile: 94
file content (81 lines) | stat: -rw-r--r-- 2,068 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
	Copyright (c) 1997,1998 Eugene G. Crosser
	Copyright (c) 1998 Bruce D. Lightner (DOS/Windows support)

	You may do virtually what you wish with this software, as long
	as the explicit reference to its original author is retained.

	THIS SOFTWARE IS PROVIDED AS IS AND COME WITH NO WARRANTY OF ANY
	KIND, EITHER EXPRESSED OR IMPLIED.  IN NO EVENT WILL THE
	COPYRIGHT HOLDER BE LIABLE FOR ANY DAMAGES RESULTING FROM THE
	USE OF THIS SOFTWARE.
*/

#ifndef _EPH_IO_H
#define _EPH_IO_H

#include <sys/types.h>
#if defined(UNIX)
#include <termios.h>
#elif defined(MSWINDOWS)
#include <windows.h>
#endif
#include <stdlib.h>

#ifndef DC1
#define DC1 0x11
#endif

#define MAX_SPEED 115200

typedef struct _eph_iob {
	void (*errorcb)(int errcode,char *errstr);
	void *(*realloccb)(void *old,size_t length);
	void (*runcb)(size_t count);
	int (*storecb)(char *data,size_t size);
	int debug;
#if defined(UNIX)
	int fd;
	struct termios savetios;
#elif defined(MSWINDOWS)
	HANDLE fd;
	DCB savedcb;
	COMMTIMEOUTS savetimeouts,worktimeouts;
#elif defined(DOS)
	int fd;
#endif
	unsigned long timeout;
} eph_iob;

eph_iob *eph_new(void (*errorcb)(int errcode,char *errstr),
		void *(*realloccb)(void *old,size_t length),
		void (*runcb)(size_t count),
		int (*storecb)(char *data,size_t size),
		int debug);
int eph_open(eph_iob *iob,char *device_name,long speed);
int eph_close(eph_iob *iob,int newmodel);
void eph_free(eph_iob *iob);

int eph_setint(eph_iob *iob,int reg,long val);
int eph_getint(eph_iob *iob,int reg,long *val);
int eph_action(eph_iob *iob,int reg,char *val,size_t length);
int eph_setvar(eph_iob *iob,int reg,char *val,size_t length);
int eph_getvar(eph_iob *iob,int reg,char **val,size_t *length);

#define ERR_BASE		10001
#define ERR_DATA_TOO_LONG	10001
#define ERR_TIMEOUT		10002
#define ERR_BADREAD		10003
#define ERR_BADDATA		10004
#define ERR_BADCRC		10005
#define ERR_BADSPEED		10006
#define ERR_NOMEM		10007
#define ERR_BADARGS		10008
#define ERR_MAX			10009

#define REG_FRAME		4
#define REG_SPEED		17
#define REG_IMG			14
#define REG_TMN			15

#endif