Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2cd392c580e6
Choose a base ref
...
head repository: ngscopeclient/scopehal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 60c4eab073a2
Choose a head ref
  • 1 commit
  • 9 files changed
  • 1 contributor

Commits on Mar 11, 2020

  1. Copy the full SHA
    60c4eab View commit details
1 change: 1 addition & 0 deletions scopehal/ProtocolDecoder.cpp
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@ using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ProtocolDecoderParameter

ProtocolDecoderParameter::ProtocolDecoderParameter(ParameterTypes type)
: m_type(type)
{
27 changes: 22 additions & 5 deletions scopehal/SCPISocketTransport.cpp
Original file line number Diff line number Diff line change
@@ -40,14 +40,26 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

SCPISocketTransport::SCPISocketTransport(string hostname, unsigned short port)
SCPISocketTransport::SCPISocketTransport(string args)
: m_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
, m_hostname(hostname)
, m_port(port)
{
LogDebug("Connecting to SCPI oscilloscope at %s:%d\n", hostname.c_str(), port);
char hostname[128];
unsigned int port = 0;
if(2 != sscanf(args.c_str(), "%127[^:]:%u", hostname, &port))
{
//default if port not specified
m_hostname = args;
m_port = 1861;
}
else
{
m_hostname = hostname;
m_port = port;
}

if(!m_socket.Connect(hostname, port))
LogDebug("Connecting to VICP oscilloscope at %s:%d\n", m_hostname.c_str(), m_port);

if(!m_socket.Connect(m_hostname, m_port))
{
LogError("Couldn't connect to socket\n");
return;
@@ -66,6 +78,11 @@ SCPISocketTransport::~SCPISocketTransport()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actual transport code

string SCPISocketTransport::GetTransportName()
{
return "lan";
}

string SCPISocketTransport::GetConnectionString()
{
char tmp[256];
5 changes: 4 additions & 1 deletion scopehal/SCPISocketTransport.h
Original file line number Diff line number Diff line change
@@ -44,16 +44,19 @@
class SCPISocketTransport : public SCPITransport
{
public:
SCPISocketTransport(std::string hostname, unsigned short port);
SCPISocketTransport(std::string args);
virtual ~SCPISocketTransport();

virtual std::string GetConnectionString();
static std::string GetTransportName();

virtual bool SendCommand(std::string cmd);
virtual std::string ReadReply();
virtual void ReadRawData(size_t len, unsigned char* buf);
virtual void SendRawData(size_t len, const unsigned char* buf);

TRANSPORT_INITPROC(SCPISocketTransport)

protected:
Socket m_socket;

29 changes: 28 additions & 1 deletion scopehal/SCPITransport.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2019 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -35,10 +35,37 @@

#include "scopehal.h"

using namespace std;

SCPITransport::CreateMapType SCPITransport::m_createprocs;

SCPITransport::SCPITransport()
{
}

SCPITransport::~SCPITransport()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Enumeration

void SCPITransport::DoAddTransportClass(string name, CreateProcType proc)
{
m_createprocs[name] = proc;
}

void SCPITransport::EnumTransports(vector<string>& names)
{
for(CreateMapType::iterator it=m_createprocs.begin(); it != m_createprocs.end(); ++it)
names.push_back(it->first);
}

SCPITransport* SCPITransport::CreateTransport(string transport, string args)
{
if(m_createprocs.find(transport) != m_createprocs.end())
return m_createprocs[transport](args);

LogError("Invalid transport name");
return NULL;
}
20 changes: 20 additions & 0 deletions scopehal/SCPITransport.h
Original file line number Diff line number Diff line change
@@ -51,6 +51,26 @@ class SCPITransport
virtual std::string ReadReply() =0;
virtual void ReadRawData(size_t len, unsigned char* buf) =0;
virtual void SendRawData(size_t len, const unsigned char* buf) =0;

public:
typedef SCPITransport* (*CreateProcType)(std::string args);
static void DoAddTransportClass(std::string name, CreateProcType proc);

static void EnumTransports(std::vector<std::string>& names);
static SCPITransport* CreateTransport(std::string transport, std::string args);

protected:
//Class enumeration
typedef std::map< std::string, CreateProcType > CreateMapType;
static CreateMapType m_createprocs;
};

#define TRANSPORT_INITPROC(T) \
static SCPITransport* CreateInstance(std::string args) \
{ \
return new T(args); \
}

#define AddTransportClass(T) SCPITransport::DoAddTransportClass(T::GetTransportName(), T::CreateInstance)

#endif
31 changes: 23 additions & 8 deletions scopehal/VICPSocketTransport.cpp
Original file line number Diff line number Diff line change
@@ -40,16 +40,26 @@ using namespace std;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

VICPSocketTransport::VICPSocketTransport(string hostname, unsigned short port)
: m_nextSequence(1)
, m_lastSequence(1)
, m_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
, m_hostname(hostname)
, m_port(port)
VICPSocketTransport::VICPSocketTransport(string args)
: m_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
{
LogDebug("Connecting to VICP oscilloscope at %s:%d\n", hostname.c_str(), port);
char hostname[128];
unsigned int port = 0;
if(2 != sscanf(args.c_str(), "%127[^:]:%u", hostname, &port))
{
//default if port not specified
m_hostname = args;
m_port = 1861;
}
else
{
m_hostname = hostname;
m_port = port;
}

if(!m_socket.Connect(hostname, port))
LogDebug("Connecting to VICP oscilloscope at %s:%d\n", m_hostname.c_str(), m_port);

if(!m_socket.Connect(m_hostname, m_port))
{
LogError("Couldn't connect to socket\n");
return;
@@ -68,6 +78,11 @@ VICPSocketTransport::~VICPSocketTransport()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Actual transport code

string VICPSocketTransport::GetTransportName()
{
return "vicp";
}

string VICPSocketTransport::GetConnectionString()
{
char tmp[256];
5 changes: 4 additions & 1 deletion scopehal/VICPSocketTransport.h
Original file line number Diff line number Diff line change
@@ -44,10 +44,11 @@
class VICPSocketTransport : public SCPITransport
{
public:
VICPSocketTransport(std::string hostname, unsigned short port);
VICPSocketTransport(std::string args);
virtual ~VICPSocketTransport();

virtual std::string GetConnectionString();
static std::string GetTransportName();

virtual bool SendCommand(std::string cmd);
virtual std::string ReadReply();
@@ -66,6 +67,8 @@ class VICPSocketTransport : public SCPITransport
OP_EOI = 0x1
};

TRANSPORT_INITPROC(VICPSocketTransport)

protected:
uint8_t GetNextSequenceNumber();

11 changes: 10 additions & 1 deletion scopehal/scopehal.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2017 Andrew D. Zonenberg *
* Copyright (c) 2012-2020 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
@@ -37,6 +37,15 @@

using namespace std;

/**
@brief Static initialization forSCPI transports
*/
void TransportStaticInit()
{
AddTransportClass(SCPISocketTransport);
AddTransportClass(VICPSocketTransport);
}

string GetDefaultChannelColor(int i)
{
const int NUM_COLORS = 12;
2 changes: 2 additions & 0 deletions scopehal/scopehal.h
Original file line number Diff line number Diff line change
@@ -70,4 +70,6 @@ uint64_t ConvertVectorSignalToScalar(std::vector<bool> bits);

std::string GetDefaultChannelColor(int i);

void TransportStaticInit();

#endif