fix portnum api bug and change its usage in rx handling code