Skip to content
Dan Kelley edited this page May 6, 2017 · 2 revisions

This will be fairly easy in cases where endian="big" was used ... and I suspect that some problems I had with interpreting bits in the past might have been in endian="little" cases. I'll take notes as I do the work here instead of in the issue report.

Overview

As illustrated below, it's only in adp.nortek.R that we use endian="little". I'll start by converting the other cases, because they will be more straightforward. I will take notes on individual files, to check that I don't break things. (I sure do wish RDI supplied a test file for inclusion in the built-test suite.)

yields

adp.nortek.R:113:            head$config <- byteToBinary(buf[o+5:6], endian="little")
adp.nortek.R:188:            user$mode <- byteToBinary(buf[o+59:60], endian="little")
adp.nortek.R:271:            ##    modeBinaryTmp <- byteToBinary(buf[o+59], endian="big")
adp.nortek.R:275:            ##    tmpb <- byteToBinary(buf[o+59+iii], endian="big")
adp.rdi.R:128:    systemConfiguration <- paste(byteToBinary(FLD[5], endian="big"), byteToBinary(FLD[6], endian="big"), sep="-")
adp.rdi.R:130:    oceDebug(debug, "FLD[4]=", byteToBinary(FLD[4], endian="big"), "(looking near the systemConfiguration bytes to find a problem)\n")
adp.rdi.R:131:    oceDebug(debug, "FLD[5]=", byteToBinary(FLD[5], endian="big"), "(should be one of the systemConfiguration bytes)\n")
adp.rdi.R:132:    oceDebug(debug, "FLD[6]=", byteToBinary(FLD[6], endian="big"), "(should be one of the systemConfiguration bytes)\n")
adp.rdi.R:133:    oceDebug(debug, "FLD[7]=", byteToBinary(FLD[7], endian="big"), "(looking near the systemConfiguration bytes to find a problem)\n")
adp.rdi.R:217:    coordTransform <- byteToBinary(FLD[26], endian="big")
adp.rdi.R:219:    bits <- substr(byteToBinary(FLD[26], endian="big"), 4, 5)    
adp.rdi.R:226:    bits <- substr(byteToBinary(FLD[26], endian="big"), 6, 6)
adp.rdi.R:229:    bits <- substr(byteToBinary(FLD[26], endian="big"), 7, 7)
adp.rdi.R:232:    bits <- substr(byteToBinary(FLD[26], endian="big"), 8, 8)
adp.rdi.R:238:    sensorSource <- byteToBinary(FLD[31], endian="big")
adp.rdi.R:239:    sensorsAvailable<- byteToBinary(FLD[32], endian="big")
adv.nortek.R:323:    res@metadata$velocityScale <- if ("0" == substr(byteToBinary(buf[vsdStart[1] + 23], endian="big"), 7, 7)) 1e-3 else 0.1e-3
adv.nortek.R:326:              byteToBinary(buf[vsdStart[1] + 23], endian="big"), ")\n")
adv.nortek.R:509:    res@metadata$orientation <- if ("0" == substr(byteToBinary(status, endian="big"), 1, 1)) "upward" else "downward"

plus some references in misc.R and oce.R about byteToBinary.