MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap

Upload page content

You can upload content for the page named below. If you change the page name, you can also upload content for another page. If the page name is empty, we derive the page name from the file name.

File to load page content from
Page name
Comment

  • Python
  • pyserial

Contents

  1. pyserial
    1. Setup port
    2. Add a existing user to existing group
    3. SlackBuild for Slackware 14 (32 bit)
    4. SlackBuild for Slackware64 14 (64 bit)
    5. Raspberry pi and raspberry pico

pyserial

Encapsulates the access for the serial port. It provides backends for Python running on Windows, Linux, BSD (possibly any POSIX compliant system), Jython and IronPython (.NET and Mono), as stated in http://pyserial.sourceforge.net/.

SlackBuild page http://slackbuilds.org/repository/14.0/python/pyserial/.

  • https://github.com/pyserial/pyserial

Setup port

   1 chmod 666 /dev/ttyUSB0
   2 stty -F /dev/ttyUSB0 raw speed 9600 -crtscts cs8 -parenb -cstopb

Add a existing user to existing group

Add existing user tony to ftp supplementary/secondary group with the usermod command using the -a option ~ i.e. add the user to the supplemental group(s). Use only with -G option:

   1 usermod -a -G dialout userx

SlackBuild for Slackware 14 (32 bit)

Run commands:

   1 su
   2 cd tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/python/pyserial.tar.gz
   4 tar xvzf pyserial.tar.gz
   5 cd pyserial
   6 wget http://pypi.python.org/packages/source/p/pyserial/pyserial-2.6.tar.gz
   7 chmod 755 pyserial.SlackBuild
   8 ./pyserial.SlackBuild
   9 installpkg /tmp/pyserial-2.6-i486-1_SBo.tgz

pyserial-2.6-i486-1_SBo.tgz

SlackBuild for Slackware64 14 (64 bit)

Run commands:

   1 su
   2 cd tmp
   3 wget http://slackbuilds.org/slackbuilds/14.0/python/pyserial.tar.gz
   4 tar xvzf pyserial.tar.gz
   5 cd pyserial
   6 wget http://pypi.python.org/packages/source/p/pyserial/pyserial-2.6.tar.gz
   7 chmod 755 pyserial.SlackBuild
   8 ./pyserial.SlackBuild
   9 installpkg /tmp/pyserial-2.6-x86_64-1_SBo.tgz 

pyserial-2.6-x86_64-1_SBo.tgz

Raspberry pi and raspberry pico

   1 pip install pyserial
   2 sudo chmod 666 /dev/ttyACM0
   3 sudo stty -F /dev/ttyACM0 raw speed 115200 -crtscts cs8 -parenb -cstopb 
   4 picocom -b 115200 --echo /dev/ttyACM0
   5 # ctrl a+x
   6 

test-serial.py

   1 import serial
   2 ser = serial.Serial('/dev/ttyACM0',115200)
   3 ser.write(b'ping\n')
   4 line = ser.readline()
   5 print(line.replace("\n",""))
   6 ser.write(b'adc2\n')
   7 line = ser.readline()
   8 print(line.replace("\n",""))
   9 ser.write(b'adc4\n')
  10 line = ser.readline()
  11 print(line.replace("\n",""))
  12 ser.close()
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01