GithubHelp home page GithubHelp logo

decoders's Introduction

Getting started

Getting the files

Clone the repository

Generate the Visual Studio project files by running protobuild.exe

Writing a decoder

  • Open the solution
    • On Windows, this is done by double-clicking the .sln file, which was generated by protobuild in the previous step
  • Add your own Class library project, i.e. MyDecoders.
    • In Visual Studio, this is done by right-clicking your solution (top line in the Solution Explorer at the top-right of your screen) and selecting Add -> New Project
    • In the forthcoming dialog, make sure Visual C# is selected on the left, which should allow you to select Class Library on the right
    • Give a meaningful name (eg MyDecoders) to you class, using the Name field at the bottom of the dialog.
  • Add the following references:
  1. LabNationInterfaces
  2. System.ComponentModel.Composition
    • In your solution explorer at the top-right of your screen, find your newly added project (eg MyDecoders) and right-click on the References entry underneath it. Select Add Reference.
    • Go to Solutions -> Projects to find the first reference
      • Make sure you put a tick before the assembly, or it will not be added!
    • Go to Assemblies for the second one
    • Verify that these 2 newly added references have been added to the list of References of the MyDeocders project!
  • Last but not least, write your decoder
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using LabNation.Interfaces;

namespace LabNation.Decoders
{
    [Export(typeof(IDecoder))]
    public class DecoderI2C : IDecoder
    {
        public DecoderDescription Description
        {
            get
            {
                return new DecoderDescription()
                {
                    Name = "Joy decoder",
                    ShortName = "Joy",
                    Author = "J. Lajoie",
                    VersionMajor = 0,
                    VersionMinor = 1,
                    Description = "A simple decoder to decode the joy in bits",
                    InputWaveformTypes = new Dictionary<string, Type>() 
                    {
                        { "Bit 0", typeof(bool)},
                        { "Bit 1", typeof(bool)},
                    },
                    Parameters = null
                };
            }
        }

        public DecoderOutput[] Decode(Dictionary<string, Array> inputWaveforms, Dictionary<string, object> parameters, double samplePeriod)
        {
            bool[] B0 = (bool[])inputWaveforms["Bit 0"];
            bool[] B1 = (bool[])inputWaveforms["Bit 1"];

            List<DecoderOutput> decoderOutputList = new List<DecoderOutput>();

            int lastUsedIndex = 0;
            for(int i = 1; i < B0.Length; i++)
            {
                DecoderOutput d = null;
                if(B0[i] != B0[lastUsedIndex] && B1[i] != B1[lastUsedIndex]) 
                    d = new DecoderOutputEvent(lastUsedIndex, i, DecoderOutputColor.Blue, "Both changed!");
                else if (B0[i] != B0[lastUsedIndex] && B1[i] == B1[lastUsedIndex])
                    d = new DecoderOutputEvent(lastUsedIndex, i, DecoderOutputColor.Yellow, "B0 changed!");
                else if (B0[i] == B0[lastUsedIndex] && B1[i] != B1[lastUsedIndex])
                    d = new DecoderOutputEvent(lastUsedIndex, i, DecoderOutputColor.Red, "B1 changed!");
                if (d != null)
                {
                    decoderOutputList.Add(d);
                    lastUsedIndex = d.EndIndex;
                }
            }

            return decoderOutputList.ToArray();
        }
    }
}

Build and use

Build the project

Copy the output DLL from the build directory (i.e. ./MyDecoders/bin/Debug/MyDecoders.dll) to <My Documents>/LabNation/Plugins

Restart the SmartScope app and enjoy your decoder

DLL location

Our approach allows a DLL file compiled on any platform, to be used on any other platform. So a DLL file compiled on Windows can be used on iOS. Just make sure the DLL is placed in the correct folder, listed below:

Platform Path
Mac /Users/<username>/LabNation/Plugins
Linux ~/LabNation/Plugins
Windows <My Documents>/LabNation/Plugins
Android <sd-card>/LabNation/Plugins
iOS See section below regarding DropBox

Fetch DLL over DropBox

For all platforms, you can access a DLL file over DropBox. To do so, in the app go to Menu -> Add decoder -> Fetch from dropbox. If never done before, this will authenticate to DropBox and create all folders required. Next, on your PC you can save the DLL file to \Dropbox\Apps\LabNation SmartScope\Plugins. All DLL files you place here can now be accessed from all your devices over dropbox!

decoders's People

Contributors

louiecaulfield avatar riemerg avatar robert44 avatar sismoke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

decoders's Issues

Decode full-duplex SPI

Currently the 4-wire SPI decoder decides whether to decode the MOSI or MISO byte in a quasi-intelligent way (1st byte is regarded as command, following bytes are regarded MISO data if MOSI is 0x00 or 0xff, MOSI otherwise).

In an application I am debugging, I want to see the MISO bytes for the full transfer. However, the dummy bytes which get shifted out on MOSI are not 0x00 or 0xff, because they come out of the receive buffer of the previous transfer which just gets reused in a neat way with DMA. They contain garbage from the previous receive (which is fine, they're just dummy bytes anyway). Apart from this, I can imagine that it would be nice to see both MOSI and MISO for devices which have real full-duplex SPI transfers, where both directions actually mean something.

Could this be added to SmartScope? Because it is a major blocker for me now. I am a programmer myself and I had a look at the decoder code, however, I'm not sure if the current decoder interface is suited for returning 2 data bytes for the same time point.

Request sample testing code.

please sir, Quickly give u console code or sample windows forms application code, for this labNation device 4 pins digital out how to build and UART Serial Commination how to create with digital outs pins or wave pin.

licensing clarification

Please add LICENSE or COPYING file to clarify under which license the source code in this repo is available.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.