refactor out packet encoding and decoding so that they can be more
easily tested.
begin writing test for this.
currently doesn't compile on rfd900a due to PSEG overflow by one
byte.
fix PSEG overflow problem.