Skip to content
Snippets Groups Projects
Commit c6412e43 authored by Dinyar Rabady's avatar Dinyar Rabady
Browse files

Replace VIO board reset with SCONE one

Still need to implement the actual reset.
Belongs to #14.
parent e5978d08
No related branches found
No related tags found
No related merge requests found
Pipeline #4528884 failed
...@@ -12,8 +12,11 @@ ...@@ -12,8 +12,11 @@
#include "tools.h" #include "tools.h"
WZDmaInputFilter::WZDmaInputFilter(size_t packetBufferSize, WZDmaInputFilter::WZDmaInputFilter(size_t packetBufferSize,
size_t nbPacketBuffers, ctrl &control) size_t nbPacketBuffers, ctrl &control,
: InputFilter(packetBufferSize, nbPacketBuffers, control) { config& conf)
: InputFilter(packetBufferSize, nbPacketBuffers, control),
sconeHost_ {conf.getSconeHost()}, sconePort_ {conf.getSconePort()},
sconeBoard_ {conf.getSconeBoard()} {
// Initialize the DMA subsystem // Initialize the DMA subsystem
if (wz_init(&dma_) < 0) { if (wz_init(&dma_) < 0) {
std::string msg = "Cannot initialize WZ DMA device"; std::string msg = "Cannot initialize WZ DMA device";
...@@ -118,7 +121,7 @@ inline ssize_t WZDmaInputFilter::read_packet(char **buffer, size_t bufferSize) { ...@@ -118,7 +121,7 @@ inline ssize_t WZDmaInputFilter::read_packet(char **buffer, size_t bufferSize) {
// Oversized packet is usually sign of link problem // Oversized packet is usually sign of link problem
// Let's try to reset the board // Let's try to reset the board
LOG(ERROR) << "Going to reset the board:"; LOG(ERROR) << "Going to reset the board:";
if (wz_reset_board() < 0) { if (reset_board(sconeHost_, sconePort_, sconeBoard_) < 0) {
LOG(ERROR) << "Reset failed"; LOG(ERROR) << "Reset failed";
} else { } else {
LOG(ERROR) << "Reset finished"; LOG(ERROR) << "Reset finished";
......
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
#include "InputFilter.h" #include "InputFilter.h"
#include "wz_dma.h" #include "wz_dma.h"
#include "config.h"
class WZDmaInputFilter: public InputFilter { class WZDmaInputFilter: public InputFilter {
public: public:
WZDmaInputFilter( size_t packetBufferSize, size_t nbPacketBuffers, ctrl& control ); WZDmaInputFilter( size_t packetBufferSize, size_t nbPacketBuffers, ctrl& control, config& conf);
virtual ~WZDmaInputFilter(); virtual ~WZDmaInputFilter();
protected: protected:
...@@ -32,6 +33,10 @@ private: ...@@ -32,6 +33,10 @@ private:
} stats; } stats;
struct wz_private dma_; struct wz_private dma_;
std::string sconeHost_;
short sconePort_;
std::string sconeBoard_;
}; };
typedef std::shared_ptr<WZDmaInputFilter> WZDmaInputFilterPtr; typedef std::shared_ptr<WZDmaInputFilter> WZDmaInputFilterPtr;
......
...@@ -58,7 +58,7 @@ int run_pipeline( int nbThreads, ctrl& control, config& conf ) ...@@ -58,7 +58,7 @@ int run_pipeline( int nbThreads, ctrl& control, config& conf )
} else if (input == config::InputType::WZDMA ) { } else if (input == config::InputType::WZDMA ) {
// Create WZ DMA reader // Create WZ DMA reader
input_filter = std::make_shared<WZDmaInputFilter>( packetBufferSize, nbPacketBuffers, control ); input_filter = std::make_shared<WZDmaInputFilter>( packetBufferSize, nbPacketBuffers, control, conf );
} else if (input == config::InputType::MICRONDMA ) { } else if (input == config::InputType::MICRONDMA ) {
......
...@@ -44,6 +44,9 @@ inline const std::string strerror(const std::string& msg) ...@@ -44,6 +44,9 @@ inline const std::string strerror(const std::string& msg)
return msg + ": " + tools::strerror(); return msg + ": " + tools::strerror();
} }
int reset_board(std::string host, short port, std::string board) {
// TODO: Reset board with libcurl
}
/* /*
* Various filesystem related utilities (will be removed once moved to C++17, or rewritten with boost) * Various filesystem related utilities (will be removed once moved to C++17, or rewritten with boost)
......
...@@ -152,61 +152,3 @@ inline void wz_stop_source(struct wz_private* wz) ...@@ -152,61 +152,3 @@ inline void wz_stop_source(struct wz_private* wz)
wz->usr_regs[0x10000/4] = 0; wz->usr_regs[0x10000/4] = 0;
asm volatile ("" : : : "memory"); asm volatile ("" : : : "memory");
} }
#include <stdio.h>
#include <arpa/inet.h>
/*
* Normally, one should write to a register. But because we don't have a support for register for
* the moment, we use a server connected to Vivado to do a reset
*/
int wz_reset_board()
{
struct sockaddr_in saddr_in;
int sock;
char buf[12];
int bytes_read;
// Fill the server address
inet_aton("127.0.0.1", &(saddr_in.sin_addr));
saddr_in.sin_family = AF_INET;
saddr_in.sin_port = htons(12345);
//print out IP address
printf("Server IP: %s\n", inet_ntoa(saddr_in.sin_addr));
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
PERROR("Socket");
return -1;
}
// Connect socket to the server
if (connect(sock, (struct sockaddr *) &saddr_in, sizeof(struct sockaddr_in)) < 0) {
PERROR("Connect");
goto error;
}
if (send(sock, "reset\n", 6, 0) < 0) {
PERROR("Send");
goto error;
}
if ((bytes_read = recv(sock, buf, sizeof(buf) - 1, 0)) < 0) {
PERROR("Recv");
goto error;
}
// Put null terminating character
buf[bytes_read] = 0;
printf("Received '%s'\n", buf);
close(sock);
printf("Finished\n");
return 0;
error:
close(sock);
return -1;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment