Last active
June 18, 2016 16:21
-
-
Save ceremcem/de23af2ae9f0d98ffa58c663179cd539 to your computer and use it in GitHub Desktop.
Hostlink protocol implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: Add tests | |
packet = "@00RD0000000157*\r" # a valid packet | |
query = (x) -> | |
// # check if input is a valid Hostlink query | |
# -------------------------------------------- | |
| /^@ # start header | |
| [0-3][0-9] # unit no, must be 00-31 | |
| [RW] # Command: [R]ead or [W]rite | |
| [RDH] # Memory type: | |
# R: Common area | |
# D: Data memory | |
# H: Holding area | |
| [0-9]{4} # Address, 0000-9999 (BCD) | |
| [0-9A-F]{4,} # Data or Size, 4 characters at least | |
| [0-9A-F]{2} # Frame Check Sequence | |
| \*\r$/ # End header | |
// .test x | |
query packet | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment