Git Product home page Git Product logo

usb-watchdog's Introduction

usb-watchdog

Original blogpost

What is it?

Python script to allow you to control a usb watchdog

How does it work?

These usb watchdogs that are available on ebay/aliexpress create a virtual serial port ( just like arduinos ) and they expect a heartbeat generated by some software. If that heartbeat is not received within a certain timeframe it will trigger its relays to shutdown and reset the computer. I've sniffed the serial port to reverse engineer the protocol which seems quite simple:

  • The USB watchdog expects you to send a number based on the corresponding ascii code. This number is the heartbeat threshold.
  • Thresholds are defined by numbers multiplied by 10. E.g. if you want to define a 10 second threshold for the heartbeat you should should send the ascii char that is equal to 1. For a 30 second threshold you should send the ascii char that is equal to 3.
  • Encode a character using its integer value as reference.
  • Sending char(255) forces a reset.
  • Sending char(128) returns information regarding status and firmware version (I'm too lazy to reverse this)

Everytime you send a heartbeat the usb watchdog saves its value and starts using it as reference. This means that if you want to change the threshold to 180 seconds, all you have to do is send a heartbeat the the ascii value that is equal to decimal 18.

Caveats

  • Avoid using very small thresholds. The last value that you sent to the usb watchdog will be used onwards. This means that if you set a threshold of 10 seconds and for some reason your computer gets reset you will then have 10 seconds to complete the boot process and start running this script again otherwise you might end up stuck in a loop.

Buy me a beer

If you find this script useful, buying me a beer would be much appreciated :)

*bitcoin:* 3Mj3v5hrx5qQhwzzWPMGwkJ8DRMCywhZFy
*bitcoin cash:* 1KDbjLM9DdsCyfDMSYHdm52r5R3BRP2dfS
*ethereum:* 0xfF7167e9ea8A4d882dd9161FC5F1560B9031A6c6
*litecoin:* MERSbMVM9NmQoDhr5ktswpaumWk8dGbyUu
*ripple:* rN1sXzZUBej2wiZSjgKtAgNRTUoFhUdt36 
*stellar:* GBYS4JGPYZI774ZIU3KNEKSDUK2E3VMXQO4AZTHAO7WU4EZRSG7QF5MG

usb-watchdog's People

Contributors

zatarra avatar phoenix09 avatar alejo281 avatar niziak avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.