Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I have been working on a python module to control a UC15 GSM/GPRS chip,
- this chip have several functionalities:
- - Sms
- - Phone calls
- - Http
- - TCP/UDP Client
- - etc.
- So i would like to build a module for those instead of having everythin
- in a huge script.
- I would like to import just the functionslity i need in the test scripts,
- maybe something like this:
- from uc15 import uc15_sms
- AFAIK this can be achieved defining a uc15_sms class in the uc15.py module
- The UC15 is controlled via serial communication,, but i have trouble
- knowing how to share the same serial port when working with more than one
- functionality.
- Proposal 1: Should i add a serial object as global in the uc15.py module
- Proposal 2: Let the user pass the serial object when constructing the class
- objects, like so
- from uc15 import UC15_Http
- from uc15 import UC15_Sms
- my_serial = serial.Serial()
- my_http = UC15_Http(my_serial)
- my_Sms = UC15_Sms(my_serial)
- Proposal 3: Just have a UC15 class with subclasses to represent each of the
- functionalities, like so:
- from uc15 import UC15
- my_serial = serial.Serial()
- my_uc15 = UC15(my_serial)
- my_uc15.Sms.send_sms(phone, msg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement