public static void printStatus(Smc device) { SmcVariables vars = device.getSmcVariables(); SmcSettings settings = new SmcSettings(device.productId); settings = device.getSmcSettings(); // Note: This format is kind of annoying but we use it for compatibility with old // SmcCmd format. For future products, we should probably use YAML. Console.WriteLine("Model: " + Smc.productIdToLongModelString(device.productId)); Console.WriteLine("Serial Number: " + device.getSerialNumber()); Console.WriteLine("Firmware Version: " + device.getFirmwareVersionString()); Console.WriteLine("Last Reset: " + device.getResetCause()); Console.WriteLine(); printErrors(vars.errorStatus, "Errors currently stopping motor"); printErrors(vars.errorOccurred, "Errors that occurred since last check"); printSerialErrors(vars.serialErrorOccurred, "Serial errors that occurred since last check"); printLimitStatus(vars.limitStatus, "Active limits"); Console.WriteLine(channelStatusFormat, "Channel", "Unlimited", "Raw", "Scaled"); printChannelStatus(vars.rc1, "RC 1"); printChannelStatus(vars.rc2, "RC 2"); printChannelStatus(vars.analog1, "Analog 1"); printChannelStatus(vars.analog2, "Analog 2"); Console.WriteLine(); Console.WriteLine("Current Speed: " + vars.speed); Console.WriteLine("Target Speed: " + vars.targetSpeed); string motorState; if (vars.speed == 0) { if (vars.brakeAmount == 0) { motorState = "Coasting"; } else { // brakeAmount should be 32. motorState = "Braking"; } } else { motorState = "Driving"; } Console.WriteLine("Motor State: " + motorState); Console.WriteLine("VIN: " + vars.vinMv.ToString() + " mV"); Console.WriteLine("Temperature A: " + Smc.temperatureToAsciiString(vars.temperatureA)); Console.WriteLine("Temperature B: " + Smc.temperatureToAsciiString(vars.temperatureB)); UInt32 currentLimitMa = device.calculateCurrentLimit( vars.currentLimit, settings.currentOffsetCalibration, settings.currentScaleCalibration); Console.WriteLine("Current limit: " + currentLimitMa + " mA"); Console.WriteLine("Raw current: " + vars.rawCurrent); Console.WriteLine("Current: " + vars.current + " mA"); Console.WriteLine("Current limiting consecutive count: " + vars.currentLimitingConsecutiveCount); Console.WriteLine("Current limiting occurrence count: " + vars.currentLimitingOccurrenceCount); Console.WriteLine("RC Period: " + Smc.rcPeriodToString(vars.rcPeriod)); Console.WriteLine("Baud rate: " + (vars.baudRateRegister == 0 ? "N/A" : (Smc.convertBaudRegisterToBps(vars.baudRateRegister).ToString() + " bps"))); uint seconds = vars.timeMs / 1000; uint minutes = seconds / 60; uint hours = minutes / 60; Console.WriteLine("Up time: {0}:{1:D2}:{2:D2}.{3:D3}", hours, minutes % 60, seconds % 60, vars.timeMs % 1000); Console.WriteLine(); const string motorLimitFormat = "{0, -18} {1,9} {2,8}"; Console.WriteLine(motorLimitFormat, "Limit", "Forward", "Reverse"); Console.WriteLine(motorLimitFormat, "Max. speed", vars.forwardLimits.maxSpeed, vars.reverseLimits.maxSpeed); Console.WriteLine(motorLimitFormat, "Starting speed", vars.forwardLimits.startingSpeed, vars.reverseLimits.startingSpeed); Console.WriteLine(motorLimitFormat, "Max. acceleration", Smc.accelDecelToString(vars.forwardLimits.maxAcceleration), Smc.accelDecelToString(vars.reverseLimits.maxAcceleration)); Console.WriteLine(motorLimitFormat, "Max. deceleration", Smc.accelDecelToString(vars.forwardLimits.maxDeceleration), Smc.accelDecelToString(vars.reverseLimits.maxDeceleration)); Console.WriteLine(motorLimitFormat, "Brake duration", vars.forwardLimits.brakeDuration, vars.reverseLimits.brakeDuration); }