Commit 0e0a3e0c authored by Manolis Surligas's avatar Manolis Surligas

Finish the AX.25 decoder and add a UDP message source block

The AX.25 decoder is now decoding the received frames.
Also, the module now provides a UDP message source block. This block
will be responsible to receive UDP packets and transform them into PMT
messages for further processing in the GNU Radio flowgraph. As the
communication with the satnogs-client will be done in the same host, we
do not have to care about packet loss.

Furthermore, the module now provides and a debug message  source block
for easy debugging.
parent 75289e11
......@@ -136,38 +136,7 @@
</param>
</block>
<block>
<key>blocks_message_debug</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>0</value>
</param>
<param>
<key>_coordinate</key>
<value>(664, 224)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>blocks_message_debug_0</value>
</param>
</block>
<block>
<key>blocks_message_strobe</key>
<key>digital_binary_slicer_fb</key>
<param>
<key>alias</key>
<value></value>
......@@ -186,7 +155,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(120, 397)</value>
<value>(752, 512)</value>
</param>
<param>
<key>_rotation</key>
......@@ -194,24 +163,16 @@
</param>
<param>
<key>id</key>
<value>blocks_message_strobe_0</value>
<value>digital_binary_slicer_fb_0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>msg</key>
<value>pmt.init_u8vector(30, [0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,8, 9])</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>period</key>
<value>100</value>
</param>
</block>
<block>
<key>qtgui_time_sink_x</key>
......@@ -245,7 +206,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(856, 390)</value>
<value>(608, 382)</value>
</param>
<param>
<key>gui_hint</key>
......@@ -553,7 +514,7 @@
</param>
<param>
<key>update_time</key>
<value>0.10</value>
<value>0.02</value>
</param>
<param>
<key>ylabel</key>
......@@ -572,6 +533,57 @@
<value>-1</value>
</param>
</block>
<block>
<key>satnogs_ax25_decoder_b</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(600, 702)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>satnogs_ax25_decoder_b_0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>promisc</key>
<value>True</value>
</param>
<param>
<key>addr</key>
<value>ABCD</value>
</param>
<param>
<key>ssid</key>
<value>0</value>
</param>
</block>
<block>
<key>satnogs_ax25_encoder_bf</key>
<param>
......@@ -600,7 +612,7 @@
</param>
<param>
<key>_coordinate</key>
<value>(536, 479)</value>
<value>(328, 487)</value>
</param>
<param>
<key>_rotation</key>
......@@ -627,17 +639,156 @@
<value>0</value>
</param>
</block>
<block>
<key>satnogs_clear_text_msg_sink</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>1</value>
</param>
<param>
<key>_coordinate</key>
<value>(856, 720)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>satnogs_clear_text_msg_sink_0</value>
</param>
</block>
<block>
<key>satnogs_debug_msg_source</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>delay</key>
<value>1</value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(88, 686)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>satnogs_debug_msg_source_0</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>msg</key>
<value>"HELLO EARTH WORLD FROM SPACE"</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>repeat</key>
<value>True</value>
</param>
</block>
<block>
<key>satnogs_udp_msg_source</key>
<param>
<key>alias</key>
<value></value>
</param>
<param>
<key>comment</key>
<value></value>
</param>
<param>
<key>affinity</key>
<value></value>
</param>
<param>
<key>_enabled</key>
<value>True</value>
</param>
<param>
<key>_coordinate</key>
<value>(64, 430)</value>
</param>
<param>
<key>_rotation</key>
<value>0</value>
</param>
<param>
<key>id</key>
<value>satnogs_udp_msg_source_0</value>
</param>
<param>
<key>addr</key>
<value>"127.0.0.1"</value>
</param>
<param>
<key>mtu</key>
<value>1500</value>
</param>
<param>
<key>maxoutbuf</key>
<value>0</value>
</param>
<param>
<key>minoutbuf</key>
<value>0</value>
</param>
<param>
<key>port</key>
<value>16886</value>
</param>
</block>
<connection>
<source_block_id>blocks_message_strobe_0</source_block_id>
<sink_block_id>blocks_message_debug_0</sink_block_id>
<source_key>strobe</source_key>
<sink_key>print</sink_key>
<source_block_id>digital_binary_slicer_fb_0</source_block_id>
<sink_block_id>satnogs_ax25_decoder_b_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>blocks_message_strobe_0</source_block_id>
<sink_block_id>satnogs_ax25_encoder_bf_0</sink_block_id>
<source_key>strobe</source_key>
<sink_key>info</sink_key>
<source_block_id>satnogs_ax25_decoder_b_0</source_block_id>
<sink_block_id>satnogs_clear_text_msg_sink_0</sink_block_id>
<source_key>pdu</source_key>
<sink_key>in</sink_key>
</connection>
<connection>
<source_block_id>satnogs_ax25_encoder_bf_0</source_block_id>
<sink_block_id>digital_binary_slicer_fb_0</sink_block_id>
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>satnogs_ax25_encoder_bf_0</source_block_id>
......@@ -645,4 +796,16 @@
<source_key>0</source_key>
<sink_key>0</sink_key>
</connection>
<connection>
<source_block_id>satnogs_debug_msg_source_0</source_block_id>
<sink_block_id>satnogs_ax25_encoder_bf_0</sink_block_id>
<source_key>msg</source_key>
<sink_key>info</sink_key>
</connection>
<connection>
<source_block_id>satnogs_udp_msg_source_0</source_block_id>
<sink_block_id>satnogs_ax25_encoder_bf_0</sink_block_id>
<source_key>msg</source_key>
<sink_key>info</sink_key>
</connection>
</flow_graph>
......@@ -24,5 +24,8 @@ install(FILES
satnogs_cw_to_symbol.xml
satnogs_afsk_decoder.xml
satnogs_sine_matched_filter_ff.xml
satnogs_ax25_encoder_bf.xml DESTINATION share/gnuradio/grc/blocks
satnogs_ax25_encoder_bf.xml
satnogs_ax25_decoder_b.xml
satnogs_udp_msg_source.xml
satnogs_debug_msg_source.xml DESTINATION share/gnuradio/grc/blocks
)
<?xml version="1.0"?>
<block>
<name>AX.25 Decoder</name>
<key>satnogs_ax25_decoder_b</key>
<category>satnogs</category>
<import>import satnogs</import>
<make>satnogs.ax25_decoder_b($addr, $ssid, $promisc)</make>
<param>
<name>Receiver Callsign</name>
<key>addr</key>
<type>string</type>
</param>
<param>
<name>Receiver SSID</name>
<key>ssid</key>
<type>int</type>
</param>
<param>
<name>Promiscuous mode</name>
<key>promisc</key>
<type>enum</type>
<option>
<name>No</name>
<key>False</key>
</option>
<option>
<name>Yes</name>
<key>True</key>
</option>
</param>
<sink>
<name>in</name>
<type>byte</type>
</sink>
<source>
<name>pdu</name>
<type>message</type>
</source>
</block>
<?xml version="1.0"?>
<block>
<name>Debug Message Source</name>
<key>satnogs_debug_msg_source</key>
<category>satnogs</category>
<import>import satnogs</import>
<make>satnogs.debug_msg_source($msg, $delay, $repeat)</make>
<param>
<name>Message</name>
<key>msg</key>
<value>"HELLO WORLD"</value>
<type>string</type>
</param>
<param>
<name>Delay (seconds)</name>
<key>delay</key>
<value>0.01</value>
<type>real</type>
</param>
<param>
<name>Repeat</name>
<key>repeat</key>
<type>enum</type>
<option>
<name>Yes</name>
<key>True</key>
</option>
<option>
<name>No</name>
<key>False</key>
</option>
</param>
<source>
<name>msg</name>
<type>message</type>
</source>
</block>
<?xml version="1.0"?>
<block>
<name>UDP Message Source</name>
<key>satnogs_udp_msg_source</key>
<category>satnogs</category>
<import>import satnogs</import>
<make>satnogs.udp_msg_source($addr, $port, $mtu)</make>
<param>
<name>IP Address</name>
<key>addr</key>
<value>"127.0.0.1"</value>
<type>string</type>
</param>
<param>
<name>UDP port</name>
<key>port</key>
<value>16886</value>
<type>int</type>
</param>
<param>
<name>MTU</name>
<key>mtu</key>
<value>1500</value>
<type>int</type>
</param>
<source>
<name>msg</name>
<type>message</type>
</source>
</block>
......@@ -35,5 +35,8 @@ install(FILES
afsk_decoder.h
sine_matched_filter_ff.h
utils.h
ax25_encoder_bf.h DESTINATION include/satnogs
ax25_encoder_bf.h
ax25_decoder_b.h
udp_msg_source.h
debug_msg_source.h DESTINATION include/satnogs
)
......@@ -157,11 +157,10 @@ namespace gr
* inserted
*/
if(type == AX25_I_FRAME){
out[i] = 0xF0;
i++;
out[i++] = 0xF0;
}
memcpy(out + i, info, info_len);
i =+ info_len;
i += info_len;
/* Compute the FCS. Ignore the first flag byte */
fcs = ax25_fcs(out + 1, i - 1);
......@@ -188,6 +187,7 @@ namespace gr
/* Leading FLAG field does not need bit stuffing */
memcpy(out, AX25_SYNC_FLAG_MAP, 8 * sizeof(float));
out_idx = 8;
/* Skip the leading and trailing FLAG field */
buffer++;
for(i = 0; i < 8 * (buffer_len - 2); i++){
......
/* -*- c++ -*- */
/*
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
*
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SATNOGS_AX25_DECODER_B_H
#define INCLUDED_SATNOGS_AX25_DECODER_B_H
#include <satnogs/api.h>
#include <gnuradio/sync_block.h>
namespace gr {
namespace satnogs {
/*!
* \brief AX.25 decoding block
* \ingroup satnogs
*
*/
class SATNOGS_API ax25_decoder_b : virtual public gr::sync_block
{
public:
typedef boost::shared_ptr<ax25_decoder_b> sptr;
/**
* AX.25 decoder block.
*
* @param addr the Callsign of the receiver
* @param ssid the SSID of the receiver
* @param promisc if set to true, all the successfully decoded frames
* are forwarded. Otherwise, only those that have as destination address
* and SSID specified by the addr and ssid parameters respectively.
*/
static sptr make(std::string addr, uint8_t ssid, bool promisc=true);
};
} // namespace satnogs
} // namespace gr
#endif /* INCLUDED_SATNOGS_AX25_DECODER_B_H */
/* -*- c++ -*- */
/*
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
*
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SATNOGS_DEBUG_MSG_SOURCE_H
#define INCLUDED_SATNOGS_DEBUG_MSG_SOURCE_H
#include <satnogs/api.h>
#include <gnuradio/block.h>
namespace gr
{
namespace satnogs
{
/*!
* \brief A block for debug reasons producing specific messages
* \ingroup satnogs
*
*/
class SATNOGS_API debug_msg_source : virtual public gr::block
{
public:
typedef boost::shared_ptr<debug_msg_source> sptr;
/**
* Debug message source block.
* @param msg the message
* @param delay delay in seconds between consecutive messages
* @param repeat if set to yes the block will produce a message every
* \p delay seconds
* @return
*/
static sptr
make (const std::string &msg, double delay, bool repeat = true);
};
} // namespace satnogs
} // namespace gr
#endif /* INCLUDED_SATNOGS_DEBUG_MSG_SOURCE_H */
/* -*- c++ -*- */
/*
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
*
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SATNOGS_UDP_MSG_SOURCE_H
#define INCLUDED_SATNOGS_UDP_MSG_SOURCE_H
#include <satnogs/api.h>
#include <gnuradio/block.h>
namespace gr
{
namespace satnogs
{
/*!
* \brief UDP message/command accepter.
*
* This block received UDP messages from localhost or other network hosts
* and produces PMT messages.
*
* \ingroup satnogs
*
*/
class SATNOGS_API udp_msg_source : virtual public gr::block
{
public:
typedef boost::shared_ptr<udp_msg_source> sptr;
/**
* Creates a UDP message accepter block
* @param addr the address to bind the UDP socket
* @param port the UDP port to wait for packets
* @param mtu the maximum MTU. Used to pre-allocate a maximum packet size
*/
static sptr
make (const std::string& addr, uint16_t port, size_t mtu = 1500);
};
} // namespace satnogs
} // namespace gr
#endif /* INCLUDED_SATNOGS_UDP_MSG_SOURCE_H */
......@@ -33,7 +33,10 @@ list(APPEND satnogs_sources
cw_to_symbol_impl.cc
afsk_decoder_impl.cc
sine_matched_filter_ff_impl.cc
ax25_encoder_bf_impl.cc )
ax25_encoder_bf_impl.cc
ax25_decoder_b_impl.cc
udp_msg_source_impl.cc
debug_msg_source_impl.cc )
set(satnogs_sources "${satnogs_sources}" PARENT_SCOPE)
if(NOT satnogs_sources)
......
/* -*- c++ -*- */
/*
* gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
*
* Copyright (C) 2016, Libre Space Foundation <http://librespacefoundation.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gnuradio/io_signature.h>
#include "ax25_decoder_b_impl.h"
#include <satnogs/log.h>
namespace gr {
namespace satnogs {
ax25_decoder_b::sptr
ax25_decoder_b::make(std::string addr, uint8_t ssid, bool promisc)
{
return gnuradio::get_initial_sptr
(new ax25_decoder_b_impl(addr, ssid, promisc));
}
/*
* The private constructor
*/
ax25_decoder_b_impl::ax25_decoder_b_impl (std::string addr, uint8_t ssid,
bool promisc) :
gr::sync_block ("ax25_decoder_b",
gr::io_signature::make (1, 1, sizeof(uint8_t)),
gr::io_signature::make (0, 0, 0)),
d_promisc(promisc),
d_state(NO_SYNC),
d_dec_b(0),
d_prev_bit(0),
d_received_bytes(0),
d_decoded_bits(0),
d_cont_1(0),
d_frame_buffer(new uint8_t[AX25_MAX_FRAME_LEN
+ AX25_MAX_ADDR_LEN