mirror of
http://172.16.0.230/r/SIF/TowerOptoSifAndSpectral.git
synced 2025-10-19 03:49:42 +08:00
添加了位置定标程序 及位置移动相关程序源码
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
/***************************************************//**
|
||||
* @file Inet4Address.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_INET4ADDRESS_H
|
||||
#define SEABREEZE_INET4ADDRESS_H
|
||||
|
||||
#include <string>
|
||||
#include "common/exceptions/IllegalArgumentException.h"
|
||||
#include "common/SeaBreeze.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
namespace seabreeze {
|
||||
class Inet4Address {
|
||||
public:
|
||||
Inet4Address();
|
||||
Inet4Address(std::string ipAddressQuads)
|
||||
throw (IllegalArgumentException);
|
||||
Inet4Address(struct in_addr *ipAddr);
|
||||
Inet4Address(const Inet4Address &that);
|
||||
~Inet4Address();
|
||||
|
||||
struct in_addr getAddress();
|
||||
|
||||
std::string getHostAddress();
|
||||
|
||||
private:
|
||||
struct in_addr in;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_INET4ADDRESS_H */
|
@ -0,0 +1,80 @@
|
||||
/***************************************************//**
|
||||
* @file Socket.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_SOCKET_H
|
||||
#define SEABREEZE_SOCKET_H
|
||||
|
||||
/* Includes */
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "common/exceptions/BusTransferException.h"
|
||||
#include "common/exceptions/BusConnectException.h"
|
||||
#include "native/network/SocketException.h"
|
||||
#include "native/network/UnknownHostException.h"
|
||||
#include "native/network/Inet4Address.h"
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class Socket {
|
||||
public:
|
||||
static Socket *create();
|
||||
|
||||
virtual ~Socket();
|
||||
|
||||
virtual void connect(Inet4Address &addr, int port)
|
||||
throw (UnknownHostException, BusConnectException) = 0;
|
||||
virtual void connect(const std::string host, int port)
|
||||
throw (UnknownHostException, BusConnectException) = 0;
|
||||
|
||||
virtual void close() throw (BusException) = 0;
|
||||
virtual bool isClosed() = 0;
|
||||
virtual bool isBound() = 0;
|
||||
|
||||
/* Socket options */
|
||||
virtual int getSOLinger() throw (SocketException) = 0;
|
||||
virtual void setSOLinger(bool enable, int linger)
|
||||
throw (SocketException) = 0;
|
||||
virtual unsigned long getReadTimeoutMillis()
|
||||
throw (SocketException) = 0;
|
||||
virtual void setReadTimeoutMillis(unsigned long timeout)
|
||||
throw (SocketException) = 0;
|
||||
|
||||
/* Data transfer */
|
||||
virtual int read(unsigned char *buffer, unsigned long length)
|
||||
throw (BusTransferException) = 0;
|
||||
virtual int write(const unsigned char *buffer, unsigned long length)
|
||||
throw (BusTransferException) = 0;
|
||||
|
||||
};
|
||||
|
||||
/* Default implementation for (otherwise) pure virtual destructor */
|
||||
inline Socket::~Socket() {}
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_SOCKET_H */
|
@ -0,0 +1,44 @@
|
||||
/***************************************************//**
|
||||
* @file SocketException.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_SOCKETEXCEPTION_H
|
||||
#define SEABREEZE_SOCKETEXCEPTION_H
|
||||
|
||||
#include "common/exceptions/BusException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class SocketException : public BusException {
|
||||
public:
|
||||
SocketException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_SOCKETEXCEPTION_H */
|
@ -0,0 +1,45 @@
|
||||
/***************************************************//**
|
||||
* @file SocketTimeoutException.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
|
||||
#ifndef SEABREEZE_SOCKETTIMEOUTEXCEPTION_H
|
||||
#define SEABREEZE_SOCKETTIMEOUTEXCEPTION_H
|
||||
|
||||
#include "native/network/SocketException.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class SocketTimeoutException : public SocketException {
|
||||
public:
|
||||
SocketTimeoutException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_SOCKETTIMEOUTEXCEPTION_H */
|
@ -0,0 +1,44 @@
|
||||
/***************************************************//**
|
||||
* @file UnknownHostException.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_UNKNOWNHOSTEXCEPTION_H
|
||||
#define SEABREEZE_UNKNOWNHOSTEXCEPTION_H
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class UnknownHostException : public std::runtime_error {
|
||||
public:
|
||||
UnknownHostException(const std::string &error);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_UNKNOWNHOSTEXCEPTION_H */
|
@ -0,0 +1,71 @@
|
||||
/***************************************************//**
|
||||
* @file NativeSocketPOSIX.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_NATIVESOCKETPOSIX_H
|
||||
#define SEABREEZE_NATIVESOCKETPOSIX_H
|
||||
|
||||
#include "native/network/Socket.h"
|
||||
#include "native/network/Inet4Address.h"
|
||||
#include "common/exceptions/BusConnectException.h"
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
class NativeSocketPOSIX : public Socket {
|
||||
public:
|
||||
NativeSocketPOSIX();
|
||||
virtual ~NativeSocketPOSIX();
|
||||
|
||||
virtual void connect(Inet4Address &addr, int port)
|
||||
throw (UnknownHostException, BusConnectException);
|
||||
virtual void connect(const std::string hostname, int port)
|
||||
throw (UnknownHostException, BusConnectException);
|
||||
|
||||
virtual void close() throw (BusException);
|
||||
virtual bool isClosed();
|
||||
virtual bool isBound();
|
||||
|
||||
virtual int getSOLinger() throw (SocketException);
|
||||
virtual void setSOLinger(bool enable, int linger) throw (SocketException);
|
||||
virtual unsigned long getReadTimeoutMillis() throw (SocketException);
|
||||
virtual void setReadTimeoutMillis(unsigned long timeout) throw (SocketException);
|
||||
|
||||
virtual int read(unsigned char *buffer, unsigned long length)
|
||||
throw (BusTransferException);
|
||||
virtual int write(const unsigned char *buffer, unsigned long length)
|
||||
throw (BusTransferException);
|
||||
|
||||
private:
|
||||
int sock;
|
||||
bool bound;
|
||||
bool closed;
|
||||
Inet4Address address;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_NATIVESOCKETPOSIX_H */
|
@ -0,0 +1,73 @@
|
||||
/***************************************************//**
|
||||
* @file NativeSocketWindows.h
|
||||
* @date February 2016
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2016, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_NATIVESOCKETWINDOWS_H
|
||||
#define SEABREEZE_NATIVESOCKETWINDOWS_H
|
||||
|
||||
#include "common/SeaBreeze.h"
|
||||
#include "native/network/Socket.h"
|
||||
#include "native/network/Inet4Address.h"
|
||||
#include "common/exceptions/BusConnectException.h"
|
||||
#include <Winsock2.h>
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
class NativeSocketWindows : public Socket {
|
||||
public:
|
||||
NativeSocketWindows();
|
||||
virtual ~NativeSocketWindows();
|
||||
|
||||
virtual void connect(Inet4Address &addr, int port)
|
||||
throw (UnknownHostException, BusConnectException);
|
||||
virtual void connect(const std::string hostname, int port)
|
||||
throw (UnknownHostException, BusConnectException);
|
||||
|
||||
virtual void close() throw (BusException);
|
||||
virtual bool isClosed();
|
||||
virtual bool isBound();
|
||||
|
||||
virtual int getSOLinger() throw (SocketException);
|
||||
virtual void setSOLinger(bool enable, int linger) throw (SocketException);
|
||||
virtual unsigned long getReadTimeoutMillis() throw (SocketException);
|
||||
virtual void setReadTimeoutMillis(unsigned long timeout) throw (SocketException);
|
||||
|
||||
virtual int read(unsigned char *buffer, unsigned long length)
|
||||
throw (BusTransferException);
|
||||
virtual int write(const unsigned char *buffer, unsigned long length)
|
||||
throw (BusTransferException);
|
||||
|
||||
private:
|
||||
SOCKET sock;
|
||||
bool bound;
|
||||
bool closed;
|
||||
Inet4Address address;
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* SEABREEZE_NATIVESOCKETWINDOWS_H */
|
@ -0,0 +1,61 @@
|
||||
/***************************************************//**
|
||||
* @file NativeRS232.h
|
||||
* @date April 21, 2011
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
******************************************************/
|
||||
|
||||
#ifndef NATIVERS232_H
|
||||
#define NATIVERS232_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define OPEN_OK 0
|
||||
#define NO_DEVICE_FOUND -1
|
||||
|
||||
void *RS232Open(char *device, int *errorCode);
|
||||
|
||||
int RS232Close(void *handle);
|
||||
|
||||
int RS232Write(void *handle, char *data, int numberOfBytes);
|
||||
|
||||
int RS232Read(void *handle, char *buffer, int numberOfBytes);
|
||||
|
||||
int RS232SetBaudRate(void *handle, int rate);
|
||||
|
||||
int RS232ClearInputBuffer(void *handle);
|
||||
|
||||
int RS232ClearOutputBuffer(void *handle);
|
||||
|
||||
int RS232WaitForWrite(void *handle);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NATIVERS232_H */
|
@ -0,0 +1,66 @@
|
||||
/***************************************************//**
|
||||
* @file RS232.h
|
||||
* @date April 2011
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_RS232_H
|
||||
#define SEABREEZE_RS232_H
|
||||
|
||||
#include "native/rs232/NativeRS232.h"
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class RS232 {
|
||||
public:
|
||||
RS232(const char *devicePath, int baudRate);
|
||||
virtual ~RS232();
|
||||
|
||||
bool open();
|
||||
bool close();
|
||||
int write(void *data, unsigned int length_bytes);
|
||||
int read(void *data, unsigned int length_bytes);
|
||||
|
||||
void setVerbose(bool v);
|
||||
bool isOpened();
|
||||
|
||||
protected:
|
||||
|
||||
/* These methods are primarily for debugging. */
|
||||
void rs232HexDump(void *x, int length, bool out);
|
||||
void hexDump(void *x, int length);
|
||||
void describeTransfer(int length, bool out);
|
||||
|
||||
void *descriptor;
|
||||
bool opened;
|
||||
bool verbose;
|
||||
char *devicePath;
|
||||
int baudRate;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,55 @@
|
||||
/***************************************************//**
|
||||
* @file NativeRS232Windows.h
|
||||
* @date April 21, 2011
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
******************************************************/
|
||||
|
||||
#ifndef NATIVERS232WINDOWS_H
|
||||
#define NATIVERS232WINDOWS_H
|
||||
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef INVALID_HANDLE_VALUE
|
||||
#define INVALID_HANDLE_VALUE (-1)
|
||||
#endif
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#define EXPORTED __declspec(dllexport) __stdcall
|
||||
#else
|
||||
#define EXPORTED __declspec(dllexport)
|
||||
#endif /* __BORLANDC__ */
|
||||
#define int64 __int64
|
||||
|
||||
#endif /* NATIVERS232WINDOWS_H */
|
@ -0,0 +1,53 @@
|
||||
/***************************************************//**
|
||||
* @file NativeSystem.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This file has declarations for the native C functions
|
||||
* needed to access certain non-portable system calls.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
#ifndef NATIVE_SYSTEM_H
|
||||
#define NATIVE_SYSTEM_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/* Native C prototypes */
|
||||
|
||||
void sleepMilliseconds(unsigned int msecs);
|
||||
int systemInitialize();
|
||||
void systemShutdown();
|
||||
|
||||
/* End of C prototypes */
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* NATIVE_SYSTEM_H */
|
@ -0,0 +1,51 @@
|
||||
/***************************************************//**
|
||||
* @file System.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* The System class provides an abstract interface to
|
||||
* certain system calls.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_SYSTEM_H
|
||||
#define SEABREEZE_SYSTEM_H
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
class System {
|
||||
public:
|
||||
System();
|
||||
virtual ~System();
|
||||
|
||||
static void sleepMilliseconds(unsigned int millis);
|
||||
static bool initialize();
|
||||
static void shutdown();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
226
othersoft/shuttercali/source/OSIF/include/native/usb/NativeUSB.h
Normal file
226
othersoft/shuttercali/source/OSIF/include/native/usb/NativeUSB.h
Normal file
@ -0,0 +1,226 @@
|
||||
/***************************************************//**
|
||||
* @file NativeUSB.h
|
||||
* @date October 31, 2007
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides a relatively simple interface for
|
||||
* opening, closing, writing to, and reading from Ocean
|
||||
* Optics USB Devices. It has been extended to provide
|
||||
* more complete USB functionality at least for Linux,
|
||||
* and equivalent functionality should be brought back
|
||||
* in for Windows and MacOSX.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
******************************************************/
|
||||
|
||||
#ifndef NATIVEUSB_H
|
||||
#define NATIVEUSB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* cplusplus */
|
||||
|
||||
#define OPEN_OK 0
|
||||
#define NO_DEVICE_FOUND -1
|
||||
#define NO_DEVICE_MATCH -2
|
||||
#define CLAIM_INTERFACE_FAILED -3
|
||||
#define CLOSE_OK 0
|
||||
#define CLOSE_ERROR -1
|
||||
#define WRITE_FAILED -1
|
||||
#define READ_FAILED -1
|
||||
#define ABORT_OK 0
|
||||
#define ABORT_FAILED -1
|
||||
#define RESET_OK 0
|
||||
#define RESET_FAILED -1
|
||||
|
||||
struct USBConfigurationDescriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned short wTotalLength;
|
||||
unsigned char bNumInterfaces;
|
||||
unsigned char bConfigurationValue;
|
||||
unsigned char iConfiguration;
|
||||
unsigned char bmAttributes;
|
||||
unsigned char MaxPower;
|
||||
};
|
||||
|
||||
struct USBDeviceDescriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned short bcdUSB;
|
||||
unsigned char bDeviceClass;
|
||||
unsigned char bDeviceSubClass;
|
||||
unsigned char bDeviceProtocol;
|
||||
unsigned char bMaxPacketSize0;
|
||||
unsigned short idVendor;
|
||||
unsigned short idProduct;
|
||||
unsigned short bcdDevice;
|
||||
unsigned char iManufacturer;
|
||||
unsigned char iProduct;
|
||||
unsigned char iSerialNumber;
|
||||
unsigned char bNumConfigurations;
|
||||
};
|
||||
|
||||
struct USBInterfaceDescriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned char bInterfaceNumber;
|
||||
unsigned char bAlternateSetting;
|
||||
unsigned char bNumEndpoints;
|
||||
unsigned char bInterfaceClass;
|
||||
unsigned char bInterfaceSubClass;
|
||||
unsigned char bInterfaceProtocol;
|
||||
unsigned char iInterface;
|
||||
};
|
||||
|
||||
struct USBEndpointDescriptor {
|
||||
unsigned char bLength;
|
||||
unsigned char bDescriptorType;
|
||||
unsigned char bEndpointAddress;
|
||||
unsigned char bmAttributes;
|
||||
unsigned short wMaxPacketSize;
|
||||
unsigned char bInterval;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This function attempts to discover all devices with the given product
|
||||
// and vendor IDs. Descriptors for each found device will be placed in the
|
||||
// provided long buffer.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// vendorID: The vendor ID to match with devices on the bus
|
||||
// productID: The product ID to match with devices on the bus
|
||||
// output: A buffer of longs that will be populated with unique IDs for each
|
||||
// device found that matches the VID and PID
|
||||
// max_devices: A limit on how many IDs can be put into the output buffer
|
||||
//
|
||||
// RETURN VALUE:
|
||||
// The number of devices successfully found, or -1 if there was an error.
|
||||
int
|
||||
USBProbeDevices(int vendorID, int productID, unsigned long *output,
|
||||
int max_devices);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This function attempts to open a device with the given product and vendor
|
||||
// ID's at the specified index.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// deviceID: The ID of a device that has been provided by probeDevices().
|
||||
// errorCode: A pointer to an integer that will be set to an error code of
|
||||
// either NO_DEVICE_FOUND or NO_DEVICE_MATCH if an error occured
|
||||
// while trying to open the device or OPEN_OK if the device was
|
||||
// found and opened.
|
||||
//
|
||||
// RETURN VALUE:
|
||||
// Returns a void pointer which equals a handle to the device if the device was
|
||||
// found and opened successfully, or NULL if the device was not opened
|
||||
// successfully. The value of the 'errorCode' parameter should be checked
|
||||
// against the following before using the handle:
|
||||
// - NO_DEVICE_FOUND signifying that no device was found with the specified ID
|
||||
// or that the device with the specified ID could not be opened
|
||||
//------------------------------------------------------------------------------
|
||||
void *
|
||||
USBOpen(unsigned long deviceID, int *errorCode);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This function attempts to close the device attached to the given handle.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// handle: The device handle obtained via the open() function.
|
||||
//
|
||||
// RETURN VALUE:
|
||||
// Returns an integer which will be equal to either:
|
||||
// - CLOSE_OK if the device was closed successfully
|
||||
// - CLOSE_ERROR if some error occured
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
USBClose(void *handle);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This function writes the given data to the device attached to the given
|
||||
// handle.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// handle: The device handle obtained via the open() function.
|
||||
// endpoint: The endpoint on the device to write the data to.
|
||||
// data: A pointer to the dynamically allocated byte array of data to be written
|
||||
// size: The number of bytes to be written
|
||||
//
|
||||
// RETURN VALUE:
|
||||
// Returns an integer which will be equal to either:
|
||||
// - The number of bytes written to the endpoint if the write was successful
|
||||
// - WRITE_FAILED if the data was not written to the device
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
USBWrite(void *handle, unsigned char endpoint, char * data, int numberOfBytes);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This function reads data from the device attached to the given handle into
|
||||
// the specified byte array.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// handle: The device handle obtained via the open() function.
|
||||
// endpoint: The endpoint on the device to read the data from.
|
||||
// data: A pointer to the dynamically allocated byte array to store the data.
|
||||
// size: The number of bytes to be read.
|
||||
//
|
||||
// RETURN VALUE:
|
||||
// Returns an integer which will be equal to either:
|
||||
// - The number of bytes read from the endpoint if the read was successful
|
||||
// - READ_FAILED if the data was not successfully read from the device
|
||||
//------------------------------------------------------------------------------
|
||||
int
|
||||
USBRead(void *handle, unsigned char endpoint, char * data, int numberOfBytes);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// This function attempts to clear any stall on the given endpoint.
|
||||
//
|
||||
// PARAMETERS:
|
||||
// handle: The device handle obtained via the open() function.
|
||||
// endpoint: The endpoint on the device to clear a stall condition on.
|
||||
//
|
||||
// RETURN VALUE:
|
||||
// No value is returned (void).
|
||||
//------------------------------------------------------------------------------
|
||||
void
|
||||
USBClearStall(void *handle, unsigned char endpoint);
|
||||
|
||||
int
|
||||
USBGetDeviceDescriptor(void *handle, struct USBDeviceDescriptor *desc);
|
||||
|
||||
int
|
||||
USBGetInterfaceDescriptor(void *handle, struct USBInterfaceDescriptor *desc);
|
||||
|
||||
int
|
||||
USBGetEndpointDescriptor(void *handle, int endpoint_index, struct USBEndpointDescriptor *desc);
|
||||
|
||||
int
|
||||
USBGetStringDescriptor(void *handle, unsigned int string_index, char *buffer, int maxLength);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* _cplusplus */
|
||||
|
||||
#endif /* NATIVEUSB_H */
|
84
othersoft/shuttercali/source/OSIF/include/native/usb/USB.h
Normal file
84
othersoft/shuttercali/source/OSIF/include/native/usb/USB.h
Normal file
@ -0,0 +1,84 @@
|
||||
/***************************************************//**
|
||||
* @file USB.h
|
||||
* @date February 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#ifndef SEABREEZE_USB_H
|
||||
#define SEABREEZE_USB_H
|
||||
|
||||
#include "native/usb/USBDiscovery.h"
|
||||
#include "native/usb/NativeUSB.h"
|
||||
#include <string>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
/* Empty declaration of USBDiscovery to deal with cross-includes */
|
||||
class USBDiscovery;
|
||||
|
||||
class USB {
|
||||
public:
|
||||
virtual ~USB();
|
||||
|
||||
bool open();
|
||||
bool close();
|
||||
int write(int endpoint, void *data, unsigned int length_bytes);
|
||||
int read(int endpoint, void *data, unsigned int length_bytes);
|
||||
void clearStall(int endpoint);
|
||||
|
||||
static void setVerbose(bool v);
|
||||
|
||||
int getDeviceDescriptor(struct USBDeviceDescriptor *desc);
|
||||
int getInterfaceDescriptor(struct USBInterfaceDescriptor *desc);
|
||||
/* Get the endpoint descriptor where index is the endpoint index. */
|
||||
int getEndpointDescriptor(int index, struct USBEndpointDescriptor *epDesc);
|
||||
std::string *getStringDescriptor(int index);
|
||||
int getMaxPacketSize();
|
||||
|
||||
bool isOpened();
|
||||
|
||||
/* This allows the USBDiscovery class to access the protected
|
||||
* constructor and act as a factory for USB instances.
|
||||
*/
|
||||
friend class USBDiscovery;
|
||||
|
||||
protected:
|
||||
|
||||
/* These methods are primarily for debugging. */
|
||||
void usbHexDump(void *x, int length, int endpoint);
|
||||
void hexDump(void *x, int length);
|
||||
void describeTransfer(const char *label, int length, void* data, int endpoint, bool hexdump);
|
||||
USB(unsigned long deviceID);
|
||||
|
||||
void *descriptor;
|
||||
bool opened;
|
||||
static bool verbose;
|
||||
unsigned long deviceID;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,64 @@
|
||||
/***************************************************//**
|
||||
* @file USBDiscovery.h
|
||||
* @date February 2012
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
#ifndef USBDISCOVERY_H
|
||||
#define USBDISCOVERY_H
|
||||
|
||||
#include "native/usb/USB.h"
|
||||
#include <vector>
|
||||
|
||||
namespace seabreeze {
|
||||
|
||||
/* Empty declaration of USB to deal with cross-includes */
|
||||
class USB;
|
||||
|
||||
class USBDiscovery {
|
||||
public:
|
||||
USBDiscovery();
|
||||
~USBDiscovery();
|
||||
|
||||
/**
|
||||
* Probes the bus for devices of the given VID and PID and returns
|
||||
* a vector of identifiers. Note that these IDs are implementation-
|
||||
* specific and are not necessarily portable between platforms. They
|
||||
* are not guaranteed to be constant from one program execution to the
|
||||
* next, though they should remain constant from one invocation of this
|
||||
* method to the next within one execution if no devices change status.
|
||||
*/
|
||||
std::vector<unsigned long> *probeDevices(int vendorID, int productID);
|
||||
|
||||
/**
|
||||
* Given an identifier from probeDevices(), create a USB interface to
|
||||
* the device that can be used to open/write/read/close the device.
|
||||
*/
|
||||
USB *createUSBInterface(unsigned long deviceID);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /* USBDISCOVERY_H */
|
@ -0,0 +1,47 @@
|
||||
/***************************************************//**
|
||||
* @file WindowsGUID.h
|
||||
* @date June 2009
|
||||
* @author Ocean Optics, Inc.
|
||||
*
|
||||
* This provides GUID definitions for supported devices.
|
||||
* These must match what appears in the .inf file for the
|
||||
* devices to be found properly through the WinUSB API.
|
||||
*
|
||||
* LICENSE:
|
||||
*
|
||||
* SeaBreeze Copyright (C) 2014, Ocean Optics Inc
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject
|
||||
* to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*******************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef SEABREEZE_WINDOWS_GUID_H
|
||||
#define SEABREEZE_WINDOWS_GUID_H
|
||||
|
||||
// {BAD36DAB-A3D2-4a0e-8B2E-DA36202187D4}
|
||||
DEFINE_GUID(GUID_DEVCLASS_OCEANOPTICS_USB,
|
||||
0xbad36dab, 0xa3d2, 0x4a0e, 0x8b, 0x2e, 0xda, 0x36, 0x20, 0x21, 0x87, 0xd4);
|
||||
|
||||
// {DBBAD306-1786-4f2e-A8AB-340D45F0653F}
|
||||
DEFINE_GUID(GUID_DEVINTERFACE_OCEANOPTICS_USB,
|
||||
0xdbbad306, 0x1786, 0x4f2e, 0xa8, 0xab, 0x34, 0xd, 0x45, 0xf0, 0x65, 0x3f);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user