SIde-Channel Analysis toolKit (SICAK)
Software toolkit for side-channel analysis
All Classes Files Functions Variables Enumerations Modules Pages
scpidevice.h
Go to the documentation of this file.
1 /*
2 * SICAK - SIde-Channel Analysis toolKit
3 * Copyright (C) 2018 Petr Socha, FIT, CTU in Prague
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18 
29 #ifndef SCPIDEVICE_H
30 #define SCPIDEVICE_H
31 
32 #include <memory>
33 #include <string>
34 #include <cstring>
35 
36 #ifdef _WIN32
37 
38 #include <visa.h>
39 
40 #else
41 
42 #include <unistd.h>
43 #include <fcntl.h>
44 
45 #endif
46 
47 #include "exceptions.hpp"
48 
55 class ScpiDevice {
56 
57 protected:
58 
59  #ifdef _WIN32
60 
61  ViSession m_defaultRM;
62  ViSession m_instrument;
63 
64  #else
65 
66  int m_osHandle;
67 
68  #endif
69 
70  bool m_opened;
71 
72 public:
73 
74  ScpiDevice();
75 
76  virtual ~ScpiDevice();
77 
79  virtual void init(const char * filename);
81  virtual void deInit();
82 
84  virtual size_t sendString(const std::string & data);
86  virtual size_t receiveString(std::string & data);
87 
89  virtual size_t queryString(const std::string & query, std::string & response);
90 
92  virtual size_t sendIEEEBlock(const std::string & command, const char * data, size_t len);
94  virtual size_t receiveIEEEBlock(char * data, size_t len);
95 
97  virtual size_t queryIEEEBlock(const std::string & query, char * response, size_t responseLen);
98 
100  virtual int checkForInstrumentErrors(std::string & response);
101 
102 };
103 
104 
105 
106 #endif /* SCPIDEVICE_H */
virtual size_t receiveIEEEBlock(char *data, size_t len)
Receive binary block of data from the device, using IEEE-488.2 data format.
Definition: scpidevice.cpp:238
SCPI device interface, using either USBTMC Linux module or VISA library.
Definition: scpidevice.h:55
This header file contains exceptions.
virtual void init(const char *filename)
Initialize the device, using either USBTMC device filename (e.g. /dev/usbtmc0) on Linux,...
Definition: scpidevice.cpp:44
virtual size_t sendString(const std::string &data)
Send string to the device.
Definition: scpidevice.cpp:96
virtual void deInit()
Deinitialize the device.
Definition: scpidevice.cpp:77
virtual int checkForInstrumentErrors(std::string &response)
Check for instrument errors.
Definition: scpidevice.cpp:324
virtual size_t queryString(const std::string &query, std::string &response)
Send query string, wait for the answer and store in response.
Definition: scpidevice.cpp:183
virtual size_t queryIEEEBlock(const std::string &query, char *response, size_t responseLen)
Send query string, wait for the IEEE-488.2 data block answer.
Definition: scpidevice.cpp:317
virtual size_t sendIEEEBlock(const std::string &command, const char *data, size_t len)
Send binary block of data to the device, using IEEE-488.2 data format.
Definition: scpidevice.cpp:190
virtual size_t receiveString(std::string &data)
Receive string from the device and store in data.
Definition: scpidevice.cpp:130