Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8716797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:10:24+00:00 2026-06-13T06:10:24+00:00

I am trying to connect to a USB digital scale. The code does connect

  • 0

I am trying to connect to a USB digital scale. The code does connect to the scale as scale.IsConnected comes true, but it hangs on scale.Read(250) where 250 should be the timeout in milliseconds, but it never return from Read.

I am using the code from this thread except one change which was due to the new version of Mike O Brien’s HID Library:

public HidDevice[] GetDevices ()
{
    HidDevice[] hidDeviceList;
            
    // Metler Toledo
    hidDeviceList = HidDevices.Enumerate(0x0eb8).ToArray();
    if (hidDeviceList.Length > 0)
        return hidDeviceList;
    
    return hidDeviceList;
}

I managed to get the scale working, take a look at Mike’s answer here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:10:25+00:00Added an answer on June 13, 2026 at 6:10 am

    I managed to get the scale working. In my callback, which runs when scale returns data, I was doing Read which is a blocking call.

    So a deadlock was created, and I should have only used ReadReport or Read. Take a look at Mike’s example below which he posted here.

    using System;
    using System.Linq;
    using System.Text;
    using HidLibrary;
    
    namespace MagtekCardReader
    {
        class Program
        {
            private const int VendorId = 0x0801;
            private const int ProductId = 0x0002;
    
            private static HidDevice _device;
    
            static void Main()
            {
                _device = HidDevices.Enumerate(VendorId, ProductId).FirstOrDefault();
    
                if (_device != null)
                {
                    _device.OpenDevice();
    
                    _device.Inserted += DeviceAttachedHandler;
                    _device.Removed += DeviceRemovedHandler;
    
                    _device.MonitorDeviceEvents = true;
    
                    _device.ReadReport(OnReport);
    
                    Console.WriteLine("Reader found, press any key to exit.");
                    Console.ReadKey();
    
                    _device.CloseDevice();
                }
                else
                {
                    Console.WriteLine("Could not find reader.");
                    Console.ReadKey();
                }
            }
    
            private static void OnReport(HidReport report)
            {
                if (!_device.IsConnected) {
                    return;
                }
    
                var cardData = new Data(report.Data);
    
                Console.WriteLine(!cardData.Error ? Encoding.ASCII.GetString(cardData.CardData) : cardData.ErrorMessage);
    
                _device.ReadReport(OnReport);
            }
    
            private static void DeviceAttachedHandler()
            {
                Console.WriteLine("Device attached.");
                _device.ReadReport(OnReport);
            }
    
            private static void DeviceRemovedHandler()
            {
                Console.WriteLine("Device removed.");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to connect my Samsung Galaxy to PC but ddms tool does not
I am running OS X 10.5 and am trying to connect to a USB
I'm trying to connect to a FTP using Apaches FTPSClient but I keep getting
Trying to connect to a SQL Server 2005 instance remotely but getting the following
When trying to connect to a server, my app does not have a very
I am trying to connect to node.js websocket using unitt ios client. But it
I'm trying to connect to https url - https://rtpubcommission.api.cj.com/wsdl/version2/realtimeCommissionServiceV2.wsdl But getting the errors (listed
Im trying to connect mysql with android but it throw me an error. Error
im trying to connect mysql in android app. Below is my code. Once i
Am trying to connect the App Delegate to the View Controller in Xcode4, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.