SHARE
TWEET

Untitled

a guest Aug 5th, 2018 26 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. I have been working on a python module to control a UC15 GSM/GPRS chip,
  2. this chip have several functionalities:
  3. - Sms
  4. - Phone calls
  5. - Http
  6. - TCP/UDP Client
  7. - etc.
  8.  
  9. So i would like to build a module for those instead of having everythin
  10. in a huge script.
  11.  
  12. I would like to import just the functionslity i need in the test scripts,
  13. maybe something like this:
  14.  
  15. from uc15 import uc15_sms
  16.  
  17. AFAIK this can be achieved defining a uc15_sms class in the uc15.py module
  18.  
  19. The UC15 is controlled via serial communication,, but i have trouble
  20. knowing how to share the same serial port when working with more than one
  21. functionality.
  22.  
  23. Proposal 1: Should i add a serial object as global in the uc15.py module
  24. Proposal 2: Let the user pass the serial object when constructing the class
  25.             objects, like so
  26.  
  27. from uc15 import UC15_Http
  28. from uc15 import UC15_Sms
  29.  
  30.             my_serial = serial.Serial()
  31.             my_http = UC15_Http(my_serial)
  32.             my_Sms = UC15_Sms(my_serial)
  33.  
  34. Proposal 3: Just have a UC15 class with subclasses to represent each of the
  35.             functionalities, like so:
  36.  
  37. from uc15 import UC15
  38.  
  39.             my_serial = serial.Serial()
  40.  
  41.             my_uc15 = UC15(my_serial)
  42.             my_uc15.Sms.send_sms(phone, msg)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top