Implement most of serial commands.