fail 'Bad parameters' unless @_=3 and $_[0] >=0 && $_[0] <32767 and exists $valid_cmd{$_[1]} and $_[2]->is_writable;