Skip to content

Commit b722f4b

Browse files
committed
get/set port protcols
1 parent 94453cb commit b722f4b

File tree

4 files changed

+76
-0
lines changed

4 files changed

+76
-0
lines changed

USERGUIDE.md

+9
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ This library provides an interface for controlling and configuring an LG290P GNS
126126
- **`bool getPortInfo(int port, uint32_t &newBaud, uint8_t &dataBits, uint8_t &parity, uint8_t &stop, uint8_t &flowControl);`**
127127
Get information about the specified port.
128128

129+
- **`bool setPortInputProtocols(int port, uint8_t newFlags);`**
130+
Enable or disable which protocols are available for input on the specified port.
131+
132+
- **`bool setPortOutputProtocols(int port, uint8_t newFlags);`**
133+
Enable or disable which protocols are available for output on the specified port.
134+
135+
- **`bool getPortProtocols(int port, uint8_t &inputFlags, uint8_t &outputFlags);`**
136+
Get which protocols are enabled or disabled on the specified port.
137+
129138
- **`bool setPPS(uint16_t duration, bool alwaysOutput, bool positivePolarity = true);`**
130139
Enable Pulse-Per-Second (PPS) output with specified parameters.
131140

keywords.txt

+3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ getMode KEYWORD2
4949
setPortBaudrate KEYWORD2
5050
setBaudrate KEYWORD2
5151
getPortInfo KEYWORD2
52+
setPortInputProtocols KEYWORD2
53+
setPortOutputProtocols KEYWORD2
54+
getPortProtocols KEYWORD2
5255
setPPS KEYWORD2
5356
disablePPS KEYWORD2
5457
getPPS KEYWORD2

src/SparkFun_LG290P_GNSS.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,43 @@ bool LG290P::getPortInfo(int port, uint32_t &newBaud, uint8_t &databits, uint8_t
463463
return ret;
464464
}
465465

466+
bool LG290P::setPortInputProtocols(int port, uint8_t newFlags)
467+
{
468+
uint8_t inputFlags, outputFlags;
469+
if (!getPortProtocols(port, inputFlags, outputFlags))
470+
return false;
471+
472+
char parms[50];
473+
snprintf(parms, sizeof parms, ",W,1,%d,%d,%d", port, newFlags, outputFlags);
474+
return sendOkCommand("PQTMCFGPROT", parms);
475+
}
476+
477+
bool LG290P::setPortOutputProtocols(int port, uint8_t newFlags)
478+
{
479+
uint8_t inputFlags, outputFlags;
480+
if (!getPortProtocols(port, inputFlags, outputFlags))
481+
return false;
482+
483+
char parms[50];
484+
snprintf(parms, sizeof parms, ",W,1,%d,%d,%d", port, inputFlags, newFlags);
485+
return sendOkCommand("PQTMCFGPROT", parms);
486+
}
487+
488+
bool LG290P::getPortProtocols(int port, uint8_t &inputFlags, uint8_t &outputFlags)
489+
{
490+
char parms[50];
491+
snprintf(parms, sizeof parms, ",R,1,%d", port);
492+
bool ok = sendOkCommand("PQTMCFGPROT", parms);
493+
if (ok)
494+
{
495+
auto packet = getCommandResponse();
496+
ok = packet[2] == "1";
497+
inputFlags = atoi(packet[4].c_str());
498+
outputFlags = atoi(packet[5].c_str());
499+
}
500+
return ok;
501+
}
502+
466503
bool LG290P::setPPS(uint16_t duration, bool alwaysOutput, bool positivePolarity)
467504
{
468505
char parms[50];

src/SparkFun_LG290P_GNSS.h

+27
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ typedef enum
4444
LG290P_RESULT_CONFIG_PRESENT,
4545
} LG290PResult;
4646

47+
enum { COM_TYPE_NMEA = 1, COM_TYPE_RTCM3 = 4 };
48+
4749
class LG290P
4850
{
4951
typedef void (*nmeaCallback)(NmeaPacket &nmea);
@@ -289,6 +291,31 @@ class LG290P
289291
*/
290292
bool getPortInfo(int port, uint32_t &newBaud, uint8_t &dataBits, uint8_t &parity, uint8_t &stop, uint8_t &flowControl);
291293

294+
/**
295+
* @brief Enable or disable the protocols available for input on the specified port
296+
* @param port the LG290P port to be configured (1, 2, or 3)
297+
* @param newFlags a bitfield: some combination of COM_TYPE_NMEA and COM_TYPE_RTCM3. 0 for disable all.
298+
* @return true if the new input protocols were enabled/disabled
299+
*/
300+
bool setPortInputProtocols(int port, uint8_t newFlags);
301+
302+
/**
303+
* @brief Enable or disable the protocols available for output on the specified port
304+
* @param port the LG290P port to be configured (1, 2, or 3)
305+
* @param newFlags a bitfield: some combination of COM_TYPE_NMEA and COM_TYPE_RTCM3. 0 for disable all.
306+
* @return true if the new output protocols were enabled/disabled
307+
*/
308+
bool setPortOutputProtocols(int port, uint8_t newFlags);
309+
310+
/**
311+
* @brief Get the current protocol enable/disable status for the specified port
312+
* @param port the LG290P port to be configured (1, 2, or 3)
313+
* @param inputFlags a reference to a bitfield: returns some combination of COM_TYPE_NMEA and COM_TYPE_RTCM3. 0 for all disabled
314+
* @param outputFlags a reference to a bitfield: returns some combination of COM_TYPE_NMEA and COM_TYPE_RTCM3. 0 for all disabled
315+
* @return true if the new protocol flags were successfully acquired
316+
*/
317+
bool getPortProtocols(int port, uint8_t &inputFlags, uint8_t &outputFlags);
318+
292319
/**
293320
* @brief Set the PPS LED and output line characteristics
294321
* @details Uses the PQTMCFGPPS command

0 commit comments

Comments
 (0)