Skip to content

Add function to ping peripheral before sending request #22

@evanugarte

Description

@evanugarte

When Quasar is running in production, we assume the printer(s)/LED sign is at a certain IP address and forward requests to it, no questions asked. This risks having a request be forwarded to a non existent device and then the SQS message deleted meaning we cannot recover the failed request.

The ping command can be used to check if a device is up at a certain IP address. To run the ping command from Node, we can use exec. An example is below:

const { exec } = require('child_process');

exec('ping <ip address>', function(error, stdout, stderr) {
  // do something with error, stdout, stderr
});

If you're unfamiliar with ping, check out this animated YouTube video.

Some things to consider

  • How do we know when the device is up/down?
    • hint: observe how the three callback function params (error, stdout, stderr) change depending on device status
  • ping normally "pings" an IP address until stopped. how do we specify only a limited number of packets?

Ideal workflow

  • watch the youtube video
  • address the above section on things to consider
  • create a function in a separate file that makes use of exec to ping a device
    • The function should return a promise, resolving true/false depending if the device is up or not.
    • If you're unfamiliar with Promises, check out this simple video.
  • incorporate your new function into the LED/Print handlers.

Metadata

Metadata

Assignees

Labels

help wantedExtra attention is neededled signfor code related to the led signprintingfor code related to printingrayquazafor a project thats really cool

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions