Closed rwu2359 closed 7 years ago
strange how when you write out your pseudo code for someone else the answer appears.. I needed to add dymo.close() otherwise it stays open but does not read
the code for languages that can read the bytes to correctly return the ray weight is something like in Groovy
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
if ( weight >= 16 ) {
LBS = (weight/16 ).toInteger()
OZ = weight.mod(16).round(2)
weight = LBS + 'lb ' + OZ + 'oz'
//or
//weight = weight + 'oz'
} else {
weight = weight + 'oz'
}
} else {
weight = String.format("%,d", raw_weight) + 'g'
}
Great that you've got it working, and thanks for the update. Sometimes rubber ducking is the best debugging tool.
I have some simple Groovy to read from DYMO M10 scales.
It works the first time when run, but then the device is never found again until a complete shutdown of the environment Any clues???