ngscopeclient 0.1-dev+51fbda87c
VICPSocketTransport.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* libscopehal *
4* *
5* Copyright (c) 2012-2024 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
37#ifndef VICPSocketTransport_h
38#define VICPSocketTransport_h
39
40#include "../xptools/Socket.h"
41
50{
51public:
52 VICPSocketTransport(const std::string& args);
53 virtual ~VICPSocketTransport();
54
55 virtual std::string GetConnectionString() override;
56
58 static std::string GetTransportName();
59
61 std::string GetHostname()
62 { return m_hostname; }
63
64 virtual bool SendCommand(const std::string& cmd) override;
65 virtual std::string ReadReply(bool endOnSemicolon = true, std::function<void(float)> progress = nullptr) override;
66 virtual size_t ReadRawData(size_t len, unsigned char* buf, std::function<void(float)> progress = nullptr) override;
67 virtual void SendRawData(size_t len, const unsigned char* buf) override;
68
69 virtual bool IsCommandBatchingSupported() override;
70 virtual bool IsConnected() override;
71
72 virtual void FlushRXBuffer() override;
73
76 {
78 OP_DATA = 0x80,
79
81 OP_REMOTE = 0x40,
82
84 OP_LOCKOUT = 0x20,
85
87 OP_CLEAR = 0x10,
88
90 OP_SRQ = 0x8,
91
93 OP_REQ = 0x4,
94
96 OP_EOI = 0x1
97 };
98
99 TRANSPORT_INITPROC(VICPSocketTransport)
100
101protected:
102 uint8_t GetNextSequenceNumber();
103
106
109
112
114 std::string m_hostname;
115
117 unsigned short m_port;
118};
119
120#endif
Abstraction of a transport layer for moving SCPI data between endpoints.
Definition: SCPITransport.h:47
Class representing a network socket.
Definition: Socket.h:63
A SCPI transport tunneled over LeCroy's Virtual Instrument Control Protocol.
Definition: VICPSocketTransport.h:50
std::string GetHostname()
Returns the hostname of the scope this transport is connected to.
Definition: VICPSocketTransport.h:61
uint8_t m_nextSequence
Next sequence number.
Definition: VICPSocketTransport.h:105
uint8_t m_lastSequence
Previous sequence number.
Definition: VICPSocketTransport.h:108
static std::string GetTransportName()
Returns the constant string "vicp".
Definition: VICPSocketTransport.cpp:101
HEADER_OPS
VICP header opcode values.
Definition: VICPSocketTransport.h:76
@ OP_REMOTE
Not used.
Definition: VICPSocketTransport.h:81
@ OP_SRQ
GPIB SRQ signal.
Definition: VICPSocketTransport.h:90
@ OP_LOCKOUT
Not used.
Definition: VICPSocketTransport.h:84
@ OP_CLEAR
Not used.
Definition: VICPSocketTransport.h:87
@ OP_EOI
GPIB EOI signal.
Definition: VICPSocketTransport.h:96
@ OP_REQ
GPIB REQ signal.
Definition: VICPSocketTransport.h:93
@ OP_DATA
Data block.
Definition: VICPSocketTransport.h:78
unsigned short m_port
Port our socket is connected to.
Definition: VICPSocketTransport.h:117
uint8_t GetNextSequenceNumber()
Gets the next sequence number to be used by a packet.
Definition: VICPSocketTransport.cpp:114
Socket m_socket
Socket for communicating with the scope.
Definition: VICPSocketTransport.h:111
std::string m_hostname
Hostname our socket is connected to.
Definition: VICPSocketTransport.h:114
VICPSocketTransport(const std::string &args)
Creates a VICP transport.
Definition: VICPSocketTransport.cpp:49