maanantai, 2. joulukuu 2019

Testing RDSSpy play stream feature

RDSSpy play stream reads RDS data (*) from TCP host:port. Default host is localhost and port is 3122.
* https://teknokoodiradio.vuodatus.net/lue/2019/11/sdr-rds-groups-to-rdsspy-spy-format-file-plugin

Set RDS source to (No Source)
rdskuva3.jpg

rdskuva2.jpg

rdskuva1.jpg

rds1.spy file content:
620356A6138554F
62031560E1CC7
6203E56145206207
620356F7C614D49
6203256D20202020
.....

using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;

namespace TCPlistener
{
    class Program
    {
        static void Main(string[] args)
        {
            TcpListener server = null;
            try
            {
                Int32 port = 3122;
                IPAddress localAddr = IPAddress.Parse("127.0.0.1");
                server = new TcpListener(localAddr, port);
                server.Start();
                NetworkStream stream = null;
                TcpClient client = null;
                while (true)
                {
                    Console.Write("Waiting for a connection... ");
                    client = server.AcceptTcpClient();
                    stream = client.GetStream();
                    Console.WriteLine("Connected!");
                    break;
                }
                using (StreamReader sr = new StreamReader("c:\\utils\\sdr\\rds1.spy"))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        line = line + Environment.NewLine;
                        byte[] rds = Encoding.ASCII.GetBytes(line);
                        stream.Write(rds, 0, rds.Length);

// some delay is needed otherwise RDSSpy produces errors
                        System.Threading.Thread.Sleep(50);
                        Console.WriteLine(line);
                    }
                }
                client.Close();
            }
            catch (SocketException e)
            {
                Console.WriteLine("SocketException: {0}", e);
            }
            finally
            {
                server.Stop();
            }

            Console.WriteLine("\nHit enter to continue...");
            Console.Read();
        }
    }
}

 

 

sunnuntai, 17. marraskuu 2019

SDR# - rds groups to Rdsspy .spy format file plugin

SDRSharp.RdsiPlugin saves RDS group data to file in Rdsspy .spy format.
SDRSharp plugins.xml magic line: <add key="Rdsi" value="SDRSharp.RdsiPlugin.RdsiPlugin,SDRSharp.RdsiPlugin"/>
Plugin dll: SDRSharp.RdsiPlugin\bin\Release\SDRSharp.RdsiPlugin.dll
https://github.com/OH1GIU-P/SDRSharp.Rdsiplugin

rds1.jpgrds2.jpg

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.IO;
using SDRSharp.Common;
using SDRSharp.Radio;

namespace SDRSharp.RdsiPlugin
{
    public partial class RdsiPluginPanel : UserControl
    {
        private bool _writeFile = false;
        private readonly ISharpControl _control;
        private StreamWriter _sw = null;

        public RdsiPluginPanel(ISharpControl control)
        {
            InitializeComponent();
            _control = control;
            labelPicode.Text = "";
            textBoxLogFile.Text = "";
        }

        public void WriteToFile(String groups, String picode)
        {
            if (_writeFile)
            {
                _sw.Write(groups);
                labelPicode.Text = picode;
            }
        }

        private void buttonStart_Click(object sender, EventArgs e)
        {
            _writeFile = false;
            textBoxLogFile.Text = "";
            labelPicode.Text = "";
            if (_sw == null)
            {
                String lf = Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") +
                "_" + _control.Frequency.ToString() + ".spy";
                try
                {
                    _sw = new StreamWriter(lf, true);
                }
                catch (IOException ex)
                {
                    textBoxLogFile.Text = ex.Message;
                    return;
                }
                buttonStart.Enabled = false;
                buttonStop.Enabled = true;
                textBoxLogFile.Text = lf;
                _writeFile = true;
            }
        }

        private void buttonStop_Click(object sender, EventArgs e)
        {
            _writeFile = false;
            labelPicode.Text = "";
            textBoxLogFile.Text = "";
            _sw.Close();
            _sw.Dispose();
            _sw = null;
            buttonStart.Enabled = true;
            buttonStop.Enabled = false;
        }

        public void Close()
        {
            if (_sw != null)
            {
                _sw.Close();
            }
        }
    }
}

 

lauantai, 26. lokakuu 2019

Neste polttoaineautomaattilla plussakortti tuplana

Ei voinut olla edellisen plussakortti tankkauksen numeroa enää muistissa koska automaatilla ei ketään ollut kun sinne menin eikä ketään poiskaan sieltä ajanut kun automaatille ajoin.

nestepa.jpg

 

tiistai, 22. lokakuu 2019

Puuvillan infotaulujen tutkailua 2

Ennen
https://teknokoodiradio.vuodatus.net/lue/2017/06/kauppakeskus-puuvillan-infotaulujen-tutkailua

Nyt pienet laatikot kadonneet uusista infotauluista.

taulu2.jpg

taulu1.jpg
 

sunnuntai, 20. lokakuu 2019

SDR# signal diagnostics logger plugin

C#, .NET Framework 4.6
Visual Studio 2019 Community edition
https://docs.microsoft.com/en-us/dotnet/api/system.device.location.geocoordinatewatcher?view=netframework-4.6

Copy SDRSharp.SDLogPlugin.dll (SDRSharp.SDLogPlugin\bin\Release) to SDR# folder and add this line to plugins.xml file <add key="SDLog" value="SDRSharp.SDLogPlugin.SDLogPlugin,SDRSharp.SDLogPlugin"/>
https://github.com/OH1GIU-P/SDLog

SDLog is SDR# Signal Diagnostics power value (dB) file logger plugin. Power value less or greater than threshold value is written into the log file with timestamp, SDR# tuned frequency, latitude and longitude (if location is enabled and available - GeoCoordinateWatcher) with tab field separator.
20191020112024    -20,71    393012500        
20191020112024    -20,73    393012500        
20191020112024    -20,73    393012500        
20191020112024    -20,74    393012500        
20191020112025    -20,74    393012500        
20191020112025    -20,72    393012500        
20191020112025    -20,72    393012500   

Log file is created in SDR# folder and each time when start button is clicked, new log file is created.

sdlp.jpg

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Device.Location;
using SDRSharp.Common;

namespace SDRSharp.SDLogPlugin
{
    public partial class SDLogPluginPanel : UserControl
    {
        private GeoCoordinateWatcher _watcher = null;
        private Control _controlSDValue = null;
        private StreamWriter _sw = null;
        private ISharpControl _sdlogplugin;
        private string _logPath = string.Empty;

        public SDLogPluginPanel(ISharpControl control)
        {
            InitializeComponent();
            _sdlogplugin = control;
            labelLogFile.Text = "";        
            labelLat.Text = "";
            labelLon.Text = "";
            labelStatus.Text = "";
            _watcher = new GeoCoordinateWatcher();
            _watcher.StatusChanged += new EventHandler<GeoPositionStatusChangedEventArgs>(watcher_StatusChanged);
            //_watcher.PositionChanged += new EventHandler<GeoPositionChangedEventArgs<GeoCoordinate>>(watcher_PositionChanged);
        }

        private void ButtonStart_Click(object sender, EventArgs e)
        {
            labelLat.Text = "";
            labelLon.Text = "";
            if (!_watcher.TryStart(false, TimeSpan.FromMilliseconds(Utils.GEOCOORDWATCHER_TIMEOUT)))
            {
                labelStatus.Text = Utils.GEOCOORDWATCHER_TIMEOUT_MSG;
            }
            else
            {
                labelStatus.Text = Utils.GEOCOORDWATCHER_START_MSG;
            }
            labelStatus.Text = labelStatus.Text + " - " + _watcher.Status.ToString();
            _controlSDValue = null;
            try
            {
                Control[] ctrls = ParentForm.Controls.Find(Utils.TXT_AVERAGE, true);
                foreach (Control c in ctrls)
                {
                    _controlSDValue = c;
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Utils.APP_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (_controlSDValue != null)
            {
                if (_sw == null)
                {
                    _sw = new StreamWriter(Application.StartupPath + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") +
                    "_" + _sdlogplugin.Frequency.ToString() + ".txt", true);
                    numericUpDownThresh.Enabled = false;
                    groupBoxOperator.Enabled = false;
                    buttonStart.Enabled = false;
                    buttonStop.Enabled = true;
                    timerSDLog.Enabled = true;
                }
            }
        }

        private void ButtonStop_Click(object sender, EventArgs e)
        {
            timerSDLog.Enabled = false;
            _watcher.Stop();
            labelStatus.Text = "";
            _sw.Close();
            _sw.Dispose();
            _sw = null;
            buttonStop.Enabled = false;
            buttonStart.Enabled = true;
            numericUpDownThresh.Enabled = true;
            groupBoxOperator.Enabled = true;
        }

        public void Close()
        {
            if (_sw != null)
            {
                _sw.Close();
            }
        }
        private void timerSDLog_Tick(object sender, EventArgs e)
        {
            decimal d;
            if (decimal.TryParse(_controlSDValue.Text.Replace("dB", "").Trim(), out d))
            {
                bool b = false;
                if (radioButtonLT.Checked)
                {
                    if (d < numericUpDownThresh.Value)
                    {
                        b = true;
                    }
                }
                else
                {
                    if (d > numericUpDownThresh.Value)
                    {
                        b = true;
                    }
                }
                if (b)
                {
                    _sw.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}\t{4}", DateTime.Now.ToString("yyyyMMddHHmmss"), d, _sdlogplugin.Frequency, labelLat.Text, labelLon.Text));
                }
            }
        }

        private void watcher_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
        {
            labelLat.Text = "";
            labelLon.Text = "";
            labelStatus.Text = "";
            switch (e.Status)
            {
                case GeoPositionStatus.Ready:
                    {
                        if (!_watcher.Position.Location.IsUnknown)
                        {
                            labelLat.Text = _watcher.Position.Location.Latitude.ToString();
                            labelLon.Text = _watcher.Position.Location.Longitude.ToString();
                        }
                        else
                        {
                            labelStatus.Text = Utils.STATUS_CANNOT_FIND_DATA;
                        }
                        break;
                    }
                case GeoPositionStatus.Initializing:
                    {
                        labelStatus.Text = Utils.STATUS_INIT;
                        break;
                    }
                case GeoPositionStatus.NoData:
                    {
                        labelStatus.Text = Utils.STATUS_NO_DATA;
                        break;
                    }
                case GeoPositionStatus.Disabled:
                    {
                        labelStatus.Text = Utils.STATUS_DISABLED;
                        break;
                    }
            }
        }

        //void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
        //{
        //    labelLat.Text = e.Position.Location.Latitude.ToString();
        //    labelLon.Text = e.Position.Location.Longitude.ToString();
        //}
    }
}