pythonpyserial

Use serial port in Python without installing external packages


I have following code:

import serial
import time

ser = serial.Serial('com4',115200,timeout=1)
while 1:
    time.sleep(10)
    print ser.readline()

I do not want to use serial module and allowed to use only standard python modules in my code.

Any quick suggestion how can I do that?


Solution

  • Pyserial is written in pure python; you can copy the serial folder into your project as a package, and it would work without installing anything.

    Alternatively you can see its source code on how to implement similar functionality on your platform (Win32?) without including the whole library.