index.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /// <reference types="node" />
  2. /// <reference types="node" />
  3. /// <reference types="node" />
  4. import { Transform, TransformCallback, TransformOptions } from 'stream';
  5. import { SpacePacket, SpacePacketHeader } from './utils';
  6. export { SpacePacket, SpacePacketHeader };
  7. /** The optional configuration object, only needed if either of the two fields of the secondary header need their length defined */
  8. export interface SpacePacketOptions extends Omit<TransformOptions, 'objectMode'> {
  9. /** The length of the Time Code Field in octets, if present */
  10. timeCodeFieldLength?: number;
  11. /** The length of the Ancillary Data Field in octets, if present */
  12. ancillaryDataFieldLength?: number;
  13. }
  14. /**
  15. * A Transform stream that accepts a stream of octet data and converts it into an object
  16. * representation of a CCSDS Space Packet. See https://public.ccsds.org/Pubs/133x0b2e1.pdf for a
  17. * description of the Space Packet format.
  18. */
  19. export declare class SpacePacketParser extends Transform {
  20. timeCodeFieldLength: number;
  21. ancillaryDataFieldLength: number;
  22. dataBuffer: Buffer;
  23. headerBuffer: Buffer;
  24. dataLength: number;
  25. expectingHeader: boolean;
  26. dataSlice: number;
  27. header?: SpacePacketHeader;
  28. /**
  29. * A Transform stream that accepts a stream of octet data and emits object representations of
  30. * CCSDS Space Packets once a packet has been completely received.
  31. * @param {Object} [options] Configuration options for the stream
  32. * @param {Number} options.timeCodeFieldLength The length of the time code field within the data
  33. * @param {Number} options.ancillaryDataFieldLength The length of the ancillary data field within the data
  34. */
  35. constructor(options?: SpacePacketOptions);
  36. /**
  37. * Bundle the header, secondary header if present, and the data into a JavaScript object to emit.
  38. * If more data has been received past the current packet, begin the process of parsing the next
  39. * packet(s).
  40. */
  41. pushCompletedPacket(): void;
  42. /**
  43. * Build the Stream's headerBuffer property from the received Buffer chunk; extract data from it
  44. * if it's complete. If there's more to the chunk than just the header, initiate handling the
  45. * packet data.
  46. * @param chunk - Build the Stream's headerBuffer property from
  47. */
  48. extractHeader(chunk: Buffer): void;
  49. _transform(chunk: Buffer, encoding: BufferEncoding, cb: TransformCallback): void;
  50. _flush(cb: TransformCallback): void;
  51. }