Add unit2minor() and use it where appropriate so that we handle units > 255 properly.
Add unit2minor() and use it where appropriate so that we handle
units > 255 properly.

Fix usio while I'm there

jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase,jrobhoward/SCADAbase