Skip to content

jglatts/SerialWedge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Serial Data Keyboard Wedge

Sends serial port data to any application (e.g., Excel, Notepad, ERP systems).
Can collect data from Serial, RS232, and RS232-via-USB industrial equipment.
Supports real-time data viewing and custom data handling.

Features

✅ Sends serial data as keyboard input
✅ Works with RS232, USB-to-Serial devices, and industrial equipment
Real-time data viewing for monitoring incoming data
Customizable serial data processing via SerialReaderBase
✅ Supports multiple baud rates and handshake methods


Compatible Devices

Device Type Examples
Barcode Readers Handheld scanners, POS systems
Weighing Scales Industrial balances, lab scales
Meters Voltage meters, pressure gauges
Calipers Digital calipers, micrometers
Sensors Temperature, force, pH sensors
Custom Devices Any RS232-based industrial tool

Builds upon https://github.com/pormiston/SerialWedge


System Screenshot

system_gui


How To Run

From GitHub Releases

  1. Go to the Releases page: SerialWedge Releases
  2. Download the latest Wedge.exe from the Assets section
  3. Run the application (no installation required)

From Source

  1. Clone the repo:
    git clone https://github.com/jglatts/SerialWedge.git
  2. Open the SLN file in VisualStudio

Creating a Custom Serial Reader for the Keyboard Wedge

To implement a custom serial reader, follow these steps:

1. Create a New Class that Inherits SerialReaderBase

Your custom serial reader must be a subclass of SerialReaderBase.
This ensures it integrates smoothly with the wedge system.

Example: Creating MyDeviceSerialReader

using System;
using System.IO.Ports;
using System.Windows.Forms;

namespace Wedgies
{
    class MyDeviceSerialReader : SerialReaderBase
    {

        /*
            Constructor for the custom serial reader.
            Calls the base class constructor to initialize the serial port and callback.
        */
        public MyDeviceSerialReader(SerialPort port, UpdateCallback callback)
            : base(port, callback)
        {
        }

        /*
            Initialize serial port settings specific to your device.
            Override this method to configure parameters like parity, data bits, stop bits, etc.
        */
        public override void initPort()
        {
            // example usage:
            port.Parity = Parity.Even;
            port.DataBits = 8;
            port.StopBits = StopBits.One;
            port.DtrEnable = true;
            port.RtsEnable = false;
        }

        /*
            Core method for reading and processing serial data.

            This method is called repeatedly in a loop while the reader is running.
            Override this method to customize how data is interpreted and processed.
        */
        public override void worker()
        {
            try
            {
                // Read a line of data from the serial port
                string line = port.ReadLine();

                // Process the data as needed
                if (string.IsNullOrEmpty(line))
                    return;

                // Example: Filter out unwanted characters
                line = line.Replace("?", "");

                // Send the processed data as keyboard input
                SendKeys.SendWait(line);

                // Invoke the callback to update UI or logs
                updateCallback?.Invoke(line);
            }
            catch (TimeoutException)
            {
                // No data available, continue
            }
        }
    }
}

2. Instantiate and Use Your Custom Reader

In frmwedge.cs, you would typically instantiate your reader like this:

public frmWedge()
{
    // constructor code

    SerialPort port = new SerialPort();
    serialReader = new MyDeviceSerialReader(port, updateLiveInput);

    // more constructor code     
}

Why This Is Effective

funny_img

About

Serial Data Keyboard Wedge in C#

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages