Merge lp:~lui-nogueira/stoqdrivers/toledo into lp:~stoq-dev/stoqdrivers/master

Proposed by Luiz Eduardo Nogueira
Status: Merged
Merged at revision: 490
Proposed branch: lp:~lui-nogueira/stoqdrivers/toledo
Merge into: lp:~stoq-dev/stoqdrivers/master
Diff against target: 58 lines (+10/-6)
2 files modified
stoqdrivers/base.py (+2/-1)
stoqdrivers/scales/toledo/PrixIII.py (+8/-5)
To merge this branch: bzr merge lp:~lui-nogueira/stoqdrivers/toledo
Reviewer Review Type Date Requested Status
Ronaldo Maia Approve
Review via email: mp+42409@code.launchpad.net

Description of the change

Atualizando código da balança

To post a comment you must log in.
Revision history for this message
Ronaldo Maia (romaia) wrote :

Perfeito

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'stoqdrivers/base.py'
2--- stoqdrivers/base.py 2009-02-11 14:33:24 +0000
3+++ stoqdrivers/base.py 2010-12-01 20:05:56 +0000
4@@ -96,6 +96,7 @@
5 % (name, class_name))
6 if not self._port:
7 self._port = SerialPort(self.device)
8+
9 self._driver = driver_class(self._port, consts=self._driver_constants)
10 log.info(("Config data: brand=%s,device=%s,model=%s"
11 % (self.brand, self.device, self.model)))
12@@ -120,7 +121,7 @@
13 is coming from the serial port. It is necessary that a gobject main
14 loop is already running before calling this method.
15 """
16- gobject.io_add_watch(self._driver.fd, gobject.IO_IN,
17+ gobject.io_add_watch(self.get_port().fd, gobject.IO_IN,
18 lambda fd, cond: func(self, cond))
19
20 def set_port(self, port):
21
22=== modified file 'stoqdrivers/scales/toledo/PrixIII.py'
23--- stoqdrivers/scales/toledo/PrixIII.py 2007-07-02 17:49:52 +0000
24+++ stoqdrivers/scales/toledo/PrixIII.py 2010-12-01 20:05:56 +0000
25@@ -32,7 +32,7 @@
26
27 from stoqdrivers.exceptions import InvalidReply
28 from stoqdrivers.interfaces import IScale, IScaleInfo
29-from stoqdrivers.serialbase import SerialBase
30+from stoqdrivers.serialbase import SerialBase, SerialPort
31
32 STX = 0x02
33 ETX = 0x03
34@@ -72,9 +72,10 @@
35
36 model_name = "Toledo Prix III"
37
38- def __init__(self, device):
39- SerialBase.__init__(self, device, baudrate=9600, bytesize=EIGHTBITS,
40- stopbits=STOPBITS_ONE, parity=PARITY_EVEN)
41+ def __init__(self, device, consts=None):
42+ SerialBase.__init__(self, device)
43+ device.set_options(baudrate=9600, bytesize=EIGHTBITS,
44+ stopbits=STOPBITS_ONE, parity=PARITY_EVEN)
45 self._package = None
46
47 def _get_package(self):
48@@ -91,8 +92,10 @@
49 def read_data(self):
50 return self._get_package()
51
52+
53 if __name__ == "__main__":
54- r = PrixIII('/dev/ttyS0')
55+ port = SerialPort('/dev/ttyS0')
56+ r = PrixIII(port)
57 print "*** PRESS THE 'PRINT' BUTTON ON THE SCALE TO READ THE DATA ***"
58 data = r.read_data()
59

Subscribers

People subscribed via source and target branches

to status/vote changes: