本文整理汇总了C++中NMEAInputLine::read_hex方法的典型用法代码示例。如果您正苦于以下问题:C++ NMEAInputLine::read_hex方法的具体用法?C++ NMEAInputLine::read_hex怎么用?C++ NMEAInputLine::read_hex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NMEAInputLine
的用法示例。
在下文中一共展示了NMEAInputLine::read_hex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// RMN: Volkslogger
// Source data:
// $PGCS,1,0EC0,FFF9,0C6E,02*61
// $PGCS,1,0EC0,FFFA,0C6E,03*18
static bool
vl_PGCS1(NMEAInputLine &line, NMEA_INFO *GPS_INFO, bool enable_baro)
{
GPS_STATE &gps = GPS_INFO->gps;
if (line.read(1) != 1)
return false;
/* pressure sensor */
line.skip();
// four characers, hex, barometric altitude
long altitude = line.read_hex(0L);
if (enable_baro) {
if (altitude > 60000)
/* Assuming that altitude has wrapped around. 60 000 m occurs
at QNH ~2000 hPa */
altitude -= 65535;
GPS_INFO->BaroAltitude =
GPS_INFO->pressure.AltitudeToQNHAltitude(fixed(altitude));
GPS_INFO->BaroAltitudeAvailable = true;
}
// ExtractParameter(String,ctemp,3);
// four characters, hex, constant. Value 1371 (dec)
// nSatellites = (int)(min(12,HexStrToDouble(ctemp, NULL)));
if (gps.SatellitesUsed <= 0) {
gps.SatellitesUsed = 4;
// just to make XCSoar quit complaining. VL doesn't tell how many
// satellites it uses. Without this XCSoar won't do wind
// measurements.
}
return false;
}
示例2:
static bool
PDSWC(NMEAInputLine &line, NMEAInfo &info)
{
static long last_switchinputs;
static long last_switchoutputs;
fixed value;
if (line.read_checked(value))
info.settings.ProvideMacCready(value / 10, info.clock);
long switchinputs = line.read_hex(0L);
long switchoutputs = line.read_hex(0L);
if (line.read_checked(value)) {
info.voltage = value / 10;
info.voltage_available.Update(info.clock);
}
info.switch_state_available = true;
info.switch_state.airbrake_locked =
(switchinputs & (1<<INPUT_BIT_AIRBRAKELOCKED))>0;
info.switch_state.flap_positive =
(switchinputs & (1<<INPUT_BIT_FLAP_POS))>0;
info.switch_state.flap_neutral =
(switchinputs & (1<<INPUT_BIT_FLAP_ZERO))>0;
info.switch_state.flap_negative =
(switchinputs & (1<<INPUT_BIT_FLAP_NEG))>0;
info.switch_state.gear_extended =
(switchinputs & (1<<INPUT_BIT_GEAR_EXTENDED))>0;
info.switch_state.acknowledge =
(switchinputs & (1<<INPUT_BIT_ACK))>0;
info.switch_state.repeat =
(switchinputs & (1<<INPUT_BIT_REP))>0;
info.switch_state.speed_command =
(switchinputs & (1<<INPUT_BIT_SC))>0;
info.switch_state.user_switch_up =
(switchinputs & (1<<INPUT_BIT_USERSWUP))>0;
info.switch_state.user_switch_middle =
(switchinputs & (1<<INPUT_BIT_USERSWMIDDLE))>0;
info.switch_state.user_switch_down =
(switchinputs & (1<<INPUT_BIT_USERSWDOWN))>0;
/*
info.switch_state.Stall =
(switchinputs & (1<<INPUT_BIT_STALL))>0;
*/
info.switch_state.flight_mode =
(switchoutputs & (1 << OUTPUT_BIT_CIRCLING)) > 0
? SwitchInfo::FlightMode::CIRCLING
: SwitchInfo::FlightMode::CRUISE;
info.switch_state.flap_landing =
(switchoutputs & (1<<OUTPUT_BIT_FLAP_LANDING))>0;
long up_switchinputs;
long down_switchinputs;
long up_switchoutputs;
long down_switchoutputs;
// detect changes to ON: on now (x) and not on before (!lastx)
// detect changes to OFF: off now (!x) and on before (lastx)
down_switchinputs = (switchinputs & (~last_switchinputs));
up_switchinputs = ((~switchinputs) & (last_switchinputs));
down_switchoutputs = (switchoutputs & (~last_switchoutputs));
up_switchoutputs = ((~switchoutputs) & (last_switchoutputs));
int i;
long thebit;
for (i=0; i<32; i++) {
thebit = 1<<i;
if ((down_switchinputs & thebit) == thebit) {
InputEvents::processNmea(i);
}
if ((down_switchoutputs & thebit) == thebit) {
InputEvents::processNmea(i+32);
}
if ((up_switchinputs & thebit) == thebit) {
InputEvents::processNmea(i+64);
}
if ((up_switchoutputs & thebit) == thebit) {
InputEvents::processNmea(i+96);
}
}
last_switchinputs = switchinputs;
last_switchoutputs = switchoutputs;
return true;
}