Giter Club home page Giter Club logo

fohhn.net's Introduction

Fohhn.Net

Simple C# 12 .NET 8.0 based functions for Fohhn-Net communication.

Table of contents

Requirements

  • Installed .NET 8.0 SDK.
  • Add Fohhn.Net.Core, Fohhn.Net.Devices and Fohhn.Net.IP or Fohhn.Net.Ports to your .NET project.

Using COM Port on Windows

Go to device manager and activate Load VCP (Virtual COM Port) in the properties of the Fohhn USB device that is displayed as USB Serial Converter. The USB device needs a reconnect to enumerate the COM Port.

Usage

Example for sending a command and receiving a reply: Always wait for a reply, or at least 350ms timeout, before sending the next command!

Node node = new IpNode("192.168.1.40"); // IP address of Fohhn device
node.DataReceived += Node_DataReceived;
byte[] cmd = Info.BuildReadCmd(1); // Fohhn-Net ID 1
replyDecoder = new ReplyDecoder(1);

node.Send(cmd);

Thread.Sleep(500); // wait before exiting the test command line application
private static ReplyDecoder replyDecoder;

private static void Node_DataReceived(object? sender, DataReceiveEventArgs e)
{
    if (replyDecoder != null)
    {
        if (replyDecoder.DecodeReceivedBytes(e.Data))
        {
            if (replyDecoder.Data != null)
            {
                ushort device = 0;
                byte[] version = [0, 0, 0];
                if(Info.ParseReadBack(replyDecoder.Data, ref device, ref version))
                {
                    Console.WriteLine(DeviceLookup.GetDeviceString(device));
                }
                else
                {
                    Console.WriteLine("invalid reply");
                }
            }
        }
    }
}

Example for using a USB Virtual COM Port:

Node node = new SerialPortNode("COM5", SerialPortNode.B19200);

License

Fohhn.Net licensed under the MIT License, see LICENSE for more information.

fohhn.net's People

Contributors

016b97 avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.