home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 August / PCO0897.ISO / filesbbs / os2 / plnk065.arj / PLNK065.ZIP / pilot-link.0.6.5 / Python / test.py < prev   
Encoding:
Python Source  |  1997-05-23  |  1.5 KB  |  71 lines

  1. import pdapilot
  2. from sys import stdin
  3.  
  4. print 'Please enter the serial port [/dev/cua3]: ',
  5. port = stdin.readline()
  6. port = port[0:len(port)-1]
  7.  
  8. if len(port) == 0:
  9.   port = '/dev/cua3'
  10.  
  11. print 'Using port',port
  12.  
  13. socket = pdapilot.OpenPort(port)
  14.  
  15. # OpenPort is the equivalent of
  16. #
  17. #socket = pdapilot.socket(pdapilot.PI_AF_SLP, pdapilot.PI_SOCK_STREAM, pdapilot.PI_PF_PADP);
  18. #
  19. #pdapilot.Bind(socket, {'family': pdapilot.PI_AF_SLP, 'port': pdapilot.PI_PilotSocketDLP,
  20. #    'device': port})
  21. #
  22. #pdapilot.Listen(socket,1)
  23.  
  24. print "Now press the HotSync button\n"
  25.  
  26. dlp = pdapilot.Accept(socket)
  27.  
  28. ui = dlp.GetUserInfo()
  29.  
  30. b = dlp.Battery()
  31.  
  32. print "Battery voltage is ", b[0], " (warning marker is ", b[1],", critical marker ", b[2], ")\n"
  33.  
  34. rpc = pdapilot.PackRPC(0xA0B6, "i", ("b", "&s", "&s", "&s", "&b", "&b"),
  35.                                     (0,   0,    0,    0,    0,    0))
  36.  
  37. b = dlp.RPC(rpc)
  38.  
  39. print "Battery results through Python RPC:", b
  40.  
  41. db = dlp.Open("MemoDB")
  42.  
  43. r = db.GetRecord(0)
  44.  
  45. print "Memo record 0 has ID ", r[2], " attribue ", r[3], ", and category ",r[4],"\n";
  46.  
  47. r2 = pdapilot.MemoUnpack(r[0]);
  48.  
  49. print "Contents: '", r2["text"], "'\n";
  50.  
  51. r3 = db.Unpack(r[0])
  52.  
  53. print "Contents (through default unpacker):", r3
  54.  
  55. app = db.GetAppBlock()
  56.  
  57. app2 = pdapilot.MemoUnpackAppBlock(app)
  58.  
  59. print "Categories are", app2["category"],"\n"
  60.  
  61. app3 = db.UnpackAppBlock(app)
  62.  
  63. print "Categories (through default unpacker) are:", app3
  64.  
  65. del db # Close database
  66.  
  67. del dlp; # Close connection
  68.  
  69. print "Your name is ", ui["name"], "\n";
  70.  
  71.