-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathopenssag.h
More file actions
executable file
·147 lines (118 loc) · 4.1 KB
/
openssag.h
File metadata and controls
executable file
·147 lines (118 loc) · 4.1 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* File: openssag.h
*
* Copyright (c) 2011 Eric J. Holmes, Orion Telescopes & Binoculars
*
*/
#ifndef __OPEN_SSAG_H__
#define __OPEN_SSAG_H__
/* Orion Telescopes VID */
#define SSAG_VENDOR_ID 0x1856
/* SSAG IO PID */
#define SSAG_PRODUCT_ID 0x0012
/* Orion Telescopes VID */
#define SSAG_LOADER_VENDOR_ID 0x1856
/* Loader PID for loading firmware */
#define SSAG_LOADER_PRODUCT_ID 0x0011
typedef struct usb_dev_handle usb_dev_handle;
#ifdef __cplusplus
namespace OpenSSAG
{
#endif
/* Struct used to return image data */
struct raw_image {
/* Image height */
unsigned int width;
/* Image width */
unsigned int height;
/* Pointer to the data. Length should be height * width */
unsigned char *data;
};
/* Guide Directions (cardinal directions) */
enum guide_direction {
guide_east = 0x10,
guide_south = 0x20,
guide_north = 0x40,
guide_west = 0x80,
};
struct device_info {
/* Null terminated string consisting of the serial number */
char serial[256];
/* Next device in list */
struct device_info *next;
};
#ifdef __cplusplus
class SSAG
{
private:
/* Sets buffer mode...or something like that */
void SetBufferMode();
/* Sends init packet and pre expose request */
void InitSequence();
/* Gets the data from the autoguider's internal buffer */
unsigned char *ReadBuffer(int timeout);
/* Holds the converted gain */
unsigned int gain;
/* Handle to the device */
usb_dev_handle *handle;
public:
/* Constructor */
SSAG();
/* Returns a linked list of device_info for the currently connected
* StarShoot Autoguiders. If there are no cameras connected, returns NULL */
struct device_info *EnumerateDevices();
/* Connect to the autoguider. If bootload is set to true and the camera
* cannot be found, it will attempt to connect to the base device and
* load the firmware. Defaults to true. */
bool Connect(bool bootload);
bool Connect();
/* Disconnect from the autoguider */
void Disconnect();
/* Returns true if the device is currently connected. */
bool IsConnected();
/* Gain should be a value between 1 and 15 */
void SetGain(int gain);
/* Expose and return the image in raw gray format. Function is blocking. */
struct raw_image *Expose(int duration);
/* Cancels an exposure */
void CancelExposure();
/* Issue a guide command through the guider relays. Guide directions
* can be OR'd together to move in X and Y at the same time.
*
* EX. Guide(guide_north | guide_west, 100, 200); */
void Guide(int direction, int yduration, int xduration);
void Guide(int direction, int duration);
/* Frees a raw_image struct */
void FreeRawImage(raw_image *image);
};
/* This class is used for loading the firmware onto the device after it is
* plugged in.
*
* See Cypress EZUSB fx2 datasheet for more information
* http://www.keil.com/dd/docs/datashts/cypress/fx2_trm.pdf */
class Loader
{
private:
/* Puts the device into reset mode by writing 0x01 to CPUCS */
void EnterResetMode();
/* Makes the device exit reset mode by writing 0x00 to CPUCS */
void ExitResetMode();
/* Sends firmware to the device */
bool Upload(unsigned char *data);
/* Handle to the cypress device */
usb_dev_handle *handle;
public:
/* Connects to SSAG Base */
bool Connect();
/* Disconnects from SSAG Base */
void Disconnect();
/* Loads the firmware into SSAG's RAM */
bool LoadFirmware();
/* Loads the SSAG eeprom onto the camera. You shouldn't use this if you
* don't know what you're doing.
* See http://www.cypress.com/?id=4&rID=34127 for more information. */
bool LoadEEPROM();
};
}
#endif // __cplusplus
#endif /* __OPEN_SSAG_H__ */