Jump to content
Server Maintenance This Week. ×

Reading from DYMO scales


This topic is 2613 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Recently bought some DYMO M10 scales and wanted to grab the weight from them.

Turns out this is not as easy as you think talking to USB, but after a lot of crashing out and frustration I managed to get a proof of concept working, so here to share...

You will need hid4java and jna, best grabbing them from Maven

 

// ReadDYMO
// 17_02_28 JR
// v1.0
// read weight from Dymo M10 scales
//requires hid4java.jar and jna.jar

import org.hid4java.*
import org.hid4java.jna.*

import java.nio.ByteBuffer

// specifc to these scales
Short VENDOR_ID = 0x0922
Short PRODUCT_ID = 0x8003

Short raw_weight = 0
DATA_MODE_OUNCES = 11

message = new byte[8]

hidServices = HidManager.getHidServices()
devices = hidServices.getAttachedHidDevices()

dymo = hidServices.getHidDevice(VENDOR_ID, PRODUCT_ID, null)

if (dymo){
	val = dymo.read(message, 1000)
	dymo.close()
} //end if

hidServices.shutdown()

if (dymo){ 
	byte[] data = [ message[5], message[4] ]
	wrapped = ByteBuffer.wrap(data)
	raw_weight = wrapped.getShort()
	if ( message[2] == DATA_MODE_OUNCES ) { 
		scale = 10.power(message[3].toString().toShort())
		weight = (raw_weight * scale) + ' oz'
		oz = true
 	} else { 
		weight = raw_weight + ' g'
		oz = false	
	} //end if
	return weight
} else {
	return '0'
} //end if

 

  • Like 1
Link to comment
Share on other sites

This topic is 2613 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.