Giter Site home page Giter Site logo

serialcompython's Introduction

SerialComPython

GitHub issues GitHub forks GitHub stars GitHub license Twitter

Serial Communication Python Class. CUI and GUI both are available.

Strong Points

  • Using a thread, TX and RX both are available at the same time.
  • Execute serial.close() and disconnect safely.

serialcompy (Python Code)

Serial Communication Python Class.

Imports

  • time: Standard library
  • threading: Standard library
  • serial (pySerial): Third-Party library (pip install pyserial)

API

SerialCom (class)              // Args: baudrate, timeout, writemode
├── devices (variable)         // comports list  
├── device (variable)          // selected comport  
├── serial (variable)          // serial.Serial instance  
├── writemode (variable)       // boolean serial write accept  
├── find_comports (method)     // Find comports and save to `self.devices`  
├── select_comport (method)    // Select a comport from list  
├── register_comport (method)  // Save a comport to `self.serial.port`  
├── open_comports (method)     // Open the comport  
├── close_comports (method)    // Close ther comport  
├── serial_write (method)      // Write strings to comport  
├── start_serialwrite (method) // Start `serial_write` in another thread  
├── serial_read (method)       // Read strings from comport  
├── start_serialcom (method)   // Start serial communication  
├── start_serialcom_option (method) // Start serial communication (using option args)  
├── get_found_devices (method)      // Return `self.devices`  
├── get_selected_device (method)    // Return `self.device`  
└── get_write_available (method)    // Return `self.writemode`

main_gui (Python Code)

  1. Startup window.
    Window Start

  2. Select a comport from the combobox. If you connect a device after the startup, push "Reload" button and check the combobox again.
    Window Select

  3. After input a baudrate, push "Open" button. If the "Baudrate" entry is empty, the rate is 9600 bps by default or the last bps you open the port.
    Window Open

  4. Input string to "Text" entry and push "Send" button. "TX" listbox is a sending history and "RX" listbox is a receiving history. Pushing "TX Export" button or "RX Export" button, you can save these histories as a text file.
    Window Send

  5. To disconnect, push "Close" button.
    Window Close

main_cui (Python Code)

  1. Select a comport.
  2. Input "yes", "y" or "no", "n".
  3. Serial communication starts.
  4. To disconnect, input Ctrl+C.
    CUI Start

SerialCom (Arduino Code)

  • 9600 bps serial communication
  • Once get a string, send it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.