Home Reference Source Repository

Function

Static Public Summary
public

Converts raw DS18B20 temperatures to ºC.

public

LIS331HH_24G(raw: *): *

public

MMA7361_6G(raw: *): *

public

Converts raw MPX4115A temperatures to hPa.

public

analogToMV(analogReadResult: *): *

public

createLogger(name: String, db: PouchDB): Bunyan

Creates a configured bunyan logger.

public

A handler for incoming Serial#data.

public

getBit(b: *, i: *): Boolean

Gets one bit out of a byte/bytes.

public

getDB(name: String): PouchDB

Gets a local database.

public

getRemoteDB(name: String, username: String, password: String): PouchDB

Gets a remote database.

public

gpsAltitude(raw: *): *

public

Convert raw coordinate object ({deg, billionths}) into an actual latitude or longitude coordinate.

public

gpsCourse(raw: *): *

public

Processes the GPS boolean flags that are crammed in one byte.

public

gpsSpeed(raw: *): *

public

Lists available ports in the system with SerialPort.list.

public

normalizePath(path: ...*): *

public

Creates and returns a "byteDelimiter" parser.

public

passEvent(sourceEmitter: EventEmitter, destEmitter: EventEmitter, sourceEvent: String, destEvent: String)

Forwards an event from one EventEmitter to another.

Static Private Summary
private

minmaxH(min: Number, max: Number): Function

Heuristic creation helper.

private

variationH(variation: Number): Function

Heuristic creation helper.

Static Public

public DS18B20(raw: Number): Number source

Converts raw DS18B20 temperatures to ºC.

Params:

NameTypeAttributeDescription
raw Number

Raw DS18B20 temperature.

Return:

Number

ºC temperature.

public LIS331HH_24G(raw: *): * source

Params:

NameTypeAttributeDescription
raw *

Return:

*

public MMA7361_6G(raw: *): * source

Params:

NameTypeAttributeDescription
raw *

Return:

*

public MPX4115A(raw: Number): Number source

Converts raw MPX4115A temperatures to hPa.

Params:

NameTypeAttributeDescription
raw Number

Raw MPX4115A pressure.

Return:

Number

hPa pressure.

public analogToMV(analogReadResult: *): * source

Params:

NameTypeAttributeDescription
analogReadResult *

Return:

*

public createLogger(name: String, db: PouchDB): Bunyan source

Creates a configured bunyan logger.

Our log output configuration:

  • Everything goes to stdout
  • debug-level or more severe messages go to a rotating file
  • info-level or more severe messages go to the database

When error-level or more severe messages are logged to the database, they include an extra "context" property with the last 30 log messages (of all levels).

Params:

NameTypeAttributeDescription
name String

Logger name.

db PouchDB

Database where logs will be stored.

Return:

Bunyan

public dataHandler(packet: Object): Promise source

A handler for incoming Serial#data. Saves packets to the local database. Should be called bound to a Station.

Params:

NameTypeAttributeDescription
packet Object

Packet to be parsed and saved.

Return:

Promise

Resolves when all is done.

public getBit(b: *, i: *): Boolean source

Gets one bit out of a byte/bytes.

Params:

NameTypeAttributeDescription
b *

{Number} The byte or bytes (up to one 32bit unsigned integer).

i *

{Number} The bit index.

Return:

Boolean

Bit value.

public getDB(name: String): PouchDB source

Gets a local database.

Params:

NameTypeAttributeDescription
name String

The database name.

Return:

PouchDB

PouchDB instance referring to the requested database.

public getRemoteDB(name: String, username: String, password: String): PouchDB source

import {getRemoteDB} from '@cansat-icarus/capture-lib/src/lib/db.js'

Gets a remote database. When provided a URL with no port, the default CouchDB ports for HTTP and HTTPS will be added automatically.

Params:

NameTypeAttributeDescription
name String

The database name or URL.

username String

The database username.

password String

The database password.

Return:

PouchDB

PouchDB instance referring to the requested database.

public gpsAltitude(raw: *): * source

Params:

NameTypeAttributeDescription
raw *

Return:

*

public gpsCoordinate(raw: Object): Number source

Convert raw coordinate object ({deg, billionths}) into an actual latitude or longitude coordinate. This does not check any sign/cardinal orientation. The coordinate is always positive.

Params:

NameTypeAttributeDescription
raw Object

Raw coordinate as {deg, billionths}.

Return:

Number

The GPS coordinate.

public gpsCourse(raw: *): * source

Params:

NameTypeAttributeDescription
raw *

Return:

*

public gpsFlags(raw: Number): Object source

Processes the GPS boolean flags that are crammed in one byte. In this order we have: latitude sign, longitude sign, location validity, speed validity, course validity and altitude validity.

Params:

NameTypeAttributeDescription
raw Number

The number (0-255) containing the flags.

Return:

Object

Flags as an object.

public gpsSpeed(raw: *): * source

Params:

NameTypeAttributeDescription
raw *

Return:

*

public listPorts(): Promise<Array> source

Lists available ports in the system with SerialPort.list. Tries to fill out vendorId and productId fields in Windows from pnpId.

Return:

Promise<Array>

Array of port information objects.

public normalizePath(path: ...*): * source

import normalizePath from '@cansat-icarus/capture-lib/src/lib/path.js'

Params:

NameTypeAttributeDescription
path ...*

Return:

*

public parser(): Function source

Creates and returns a "byteDelimiter" parser. DISCLAIMER: It's a patched version of node-serialport's byteDelimiter parser. You can find it's source here: https://github.com/EmergingTechnologyAdvisors/node-serialport/tree/master/lib/parsers.js Changes from the original: trailing delimiters are removed, buffer passes through packetParser.parse before being emitted and empty buffers and 'Transceiver MODE' messages are ignored. Separates packets by a byte delimiter and passes them through packetParser

Return:

Function

The parser itself

public passEvent(sourceEmitter: EventEmitter, destEmitter: EventEmitter, sourceEvent: String, destEvent: String) source

Forwards an event from one EventEmitter to another.

Params:

NameTypeAttributeDescription
sourceEmitter EventEmitter

EventEmitter to be listened.

destEmitter EventEmitter

EventEmitter to where the event will be forwarded.

sourceEvent String

Event name to be listened to.

destEvent String
  • optional
  • default: sourceEvent

Event name in the source

Static Private

private minmaxH(min: Number, max: Number): Function source

Heuristic creation helper. Fails when value leaves a certain interval: [min, max].

Params:

NameTypeAttributeDescription
min Number

Minimum value.

max Number

Maximum value.

Return:

Function

The heuristic function.

private variationH(variation: Number): Function source

Heuristic creation helper. Fails when a value jumps up or down a number greater than [variation].

Params:

NameTypeAttributeDescription
variation Number

Maximum variation between packets to be expected.

Return:

Function

The heuristic function.