pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread alexandre_irrthum
Hi there,

I am trying to use pyserial to read data from a temperature logger
device (T-logger). T-logger is based on the DS1615 temperature recorder
chip (Dallas Semiconductor). According to the DS1615 docs, writing to
the chip is performed one byte  at a time. To read from the chip, one
must issue the read page command (33h), followed by the two-byte
address of the requested page (pages are 32 bytes long). After
receiving this, the DS1615 will send the data in a burst of (up to) 32
bytes. I can send data to the device, e.g. I can make the device's LED
blink with the test command (44h), but I am unable to read from it.
Connection parameters below are according to DS1615 docs.

 import serial
 s = serial.Serial(0, baudrate=9600, bytesize=8, parity='N', stopbits=1, 
 timeout=None)
 s.write(\x33)
 s.write(\x00)
 s.write(\x00)
 s.read()   # \x00 is returned here. This byte was already in the receive 
 buffer before issueing the write commands.
 s.read()   # The interpreter is blocked here as there is nothing to read 
 from the serial port.

I'm completely clueless and would really appreciate your comments. If
it helps, I can post a log from a serial port monitor captured when the
provided T-logger program pulls data from the device, as well as a log
when pyserial is used. And finally, this is a snippet of some basic
code found on the web, that is suppose to do what I want (untested by
me):

open COM1:9600,N,8,1,CS0,DS0,CD0,ME,FE as 1
print #1, chr$(H33);chr$(H00);chr$(H00)
result$ = input$(34, #1)

Many thanks,

alex

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread Gerhard Fiedler
On 2006-07-24 14:03:30, [EMAIL PROTECTED] wrote:

 To read from the chip, one must issue the read page command (33h),
 followed by the two-byte address of the requested page (pages are 32
 bytes long). After receiving this, the DS1615 will send the data in a
 burst of (up to) 32 bytes. 

I'm not sure what you mean when you say it will send up to 32 bytes. If
you mean that it sends bytes until all existing values have been sent --
did you make sure you have any values in the buffer?

(Just asking the obvious... :)

Gerhard

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread Grant Edwards
On 2006-07-24, Gerhard Fiedler [EMAIL PROTECTED] wrote:
 On 2006-07-24 14:03:30, [EMAIL PROTECTED] wrote:

 To read from the chip, one must issue the read page command (33h),
 followed by the two-byte address of the requested page (pages are 32
 bytes long). After receiving this, the DS1615 will send the data in a
 burst of (up to) 32 bytes. 

 I'm not sure what you mean when you say it will send up to 32 bytes.

Registers are in 32-byte pages.  If you request register N, the
device sends register N followed by the remainder of the
32-byte page that contains address N.  If you request the first
register on a page, you'll get 32 bytes back.  If you request
the last register on a page, you'll get one 1 back.

-- 
Grant Edwards   grante Yow!  If I pull this SWITCH
  at   I'll be RITA HAYWORTH!! Or
   visi.coma SCIENTOLOGIST!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread Grant Edwards
On 2006-07-24, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 import serial
 s = serial.Serial(0, baudrate=9600, bytesize=8, parity='N', stopbits=1, 
 timeout=None)
 s.write(\x33)
 s.write(\x00)
 s.write(\x00)
 s.read()   # \x00 is returned here. This byte was already in the receive 
 buffer before issueing the write commands.
 s.read()   # The interpreter is blocked here as there is nothing to read 
 from the serial port.

Can you verify that the device is actually responding by
watching the data line with an oscilloscope?

 I'm completely clueless and would really appreciate your
 comments. If it helps, I can post a log from a serial port
 monitor captured when the provided T-logger program pulls data
 from the device,

I take it that means that other programs are able to read from
the device?

 as well as a log when pyserial is used.

Logs of the serial traffic would be helpful.

-- 
Grant Edwards   grante Yow!  It's the land of
  at   DONNY AND MARIE as promised
   visi.comin TV GUIDE!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread alexandre_irrthum
Gerhard Fiedler wrote:
 On 2006-07-24 14:03:30, [EMAIL PROTECTED] wrote:

  To read from the chip, one must issue the read page command (33h),
  followed by the two-byte address of the requested page (pages are 32
  bytes long). After receiving this, the DS1615 will send the data in a
  burst of (up to) 32 bytes.

 I'm not sure what you mean when you say it will send up to 32 bytes. If
 you mean that it sends bytes until all existing values have been sent --
 did you make sure you have any values in the buffer?

 (Just asking the obvious... :)

 Gerhard

Thanks Gerhard,

Up to 32 bytes means that the chip sends the bytes from the address you
give up to the end of the memory page that contains this address. Thus
if you give the address of the beginning of a memory page (e.g. like
here H for the beginning of the first page, which contains control
registers and the current temperature register), you get 32 bytes.

alex

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread alexandre_irrthum
Thanks Grant,

 Can you verify that the device is actually responding by
 watching the data line with an oscilloscope?

I don't have an oscilloscope but the device does respond (LED blinks)
when I send it a test command (44H).

 I take it that means that other programs are able to read from
 the device?

Yes, the device comes with a little GUI program to read the logged
temperatures, calibrate, etc... Works fine, but I would like to read
distributed loggers over the network with python and sockets.

 Logs of the serial traffic would be helpful.

Here they are. First a log of the traffic generated by the T-logger GUI
program, abtained with Portmon.

### TRAFFIC WHEN THE PROGRAM IS LAUNCHED:

0  0.  TLogger.exe  IRP_MJ_CREATE  Serial0  Options: Open
0  0.6174  SUCCESS
1  0.  TLogger.exe  IOCTL_SERIAL_SET_WAIT_MASK  Serial0  Mask:
RXCHAR TXEMPTY CTS DSR RLSD BRK ERR RING
1  0.0726  SUCCESS
2  0.  TLogger.exe  IOCTL_SERIAL_PURGE  Serial0  Purge: TXABORT
RXABORT TXCLEAR RXCLEAR
2  0.0698  SUCCESS
3  0.  TLogger.exe  IOCTL_SERIAL_SET_TIMEOUTS  Serial0  RI:-1
RM:0 RC:0 WM:0 WC:5000
3  0.0168  SUCCESS
4  0.  TLogger.exe  IOCTL_SERIAL_GET_BAUD_RATE  Serial0
4  0.0279  SUCCESS
5  0.  TLogger.exe  IOCTL_SERIAL_GET_LINE_CONTROL  Serial0
5  0.0196  SUCCESS
6  0.  TLogger.exe  IOCTL_SERIAL_GET_CHARS  Serial0
6  0.0223  SUCCESS
7  0.  TLogger.exe  IOCTL_SERIAL_GET_HANDFLOW  Serial0
7  0.0196  SUCCESS
8  0.  TLogger.exe  IOCTL_SERIAL_GET_BAUD_RATE  Serial0
8  0.0196  SUCCESS
9  0.  TLogger.exe  IOCTL_SERIAL_GET_LINE_CONTROL  Serial0
9  0.0168  SUCCESS
10  0.  TLogger.exe  IOCTL_SERIAL_GET_CHARS  Serial0
10  0.0168  SUCCESS
11  0.  TLogger.exe  IOCTL_SERIAL_GET_HANDFLOW  Serial0
11  0.0168  SUCCESS
12  0.  TLogger.exe  IOCTL_SERIAL_SET_BAUD_RATE  Serial0  Rate:
9600
12  0.1285  SUCCESS
13  0.  TLogger.exe  IOCTL_SERIAL_CLR_RTS  Serial0
13  0.0782  SUCCESS
14  0.  TLogger.exe  IOCTL_SERIAL_SET_DTR  Serial0
14  0.0810  SUCCESS
15  0.  TLogger.exe  IOCTL_SERIAL_SET_LINE_CONTROL  Serial0
StopBits: ERROR Parity: NONE WordLength: 8
15  0.0698  SUCCESS
16  0.  TLogger.exe  IOCTL_SERIAL_SET_CHAR  Serial0  EOF:1a
ERR:0 BRK:0 EVT:0 XON:11 XOFF:13
16  0.0531  SUCCESS
17  0.  TLogger.exe  IOCTL_SERIAL_SET_HANDFLOW  Serial0
Shake:1 Replace:0 XonLimit:8 XoffLimit:8
17  0.0754  SUCCESS
18  0.  TLogger.exe  IOCTL_SERIAL_SET_WAIT_MASK  Serial0  Mask:
RXCHAR TXEMPTY CTS DSR RLSD BRK ERR RING
18  0.1145  SUCCESS
19  0.  TLogger.exe  IOCTL_SERIAL_SET_WAIT_MASK  Serial0  Mask:
RXCHAR TXEMPTY CTS DSR RLSD BRK ERR RING
19  0.0531  SUCCESS
20  0.  TLogger.exe  IOCTL_SERIAL_WAIT_ON_MASK  Serial0

### TRAFFIC WHEN THE PROGRAM READS CURRENT TEMP FROM DEVICE:

21  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
21  0.1034  SUCCESS
22  0.  TLogger.exe  IRP_MJ_WRITE  Serial0  Length 1: 33
22  0.3269  SUCCESS
20  9.28649032  SUCCESS
23  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
23  0.0587  SUCCESS
24  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
24  0.0559  SUCCESS
25  0.  TLogger.exe  IOCTL_SERIAL_GET_PROPERTIES  Serial0
25  0.0168  SUCCESS
26  0.  TLogger.exe  IRP_MJ_WRITE  Serial0  Length 1: 00
27  0.  TLogger.exe  IOCTL_SERIAL_SET_WAIT_MASK  Serial0  Mask:
RXCHAR TXEMPTY CTS DSR RLSD BRK ERR RING
27  0.0726  SUCCESS
28  0.  TLogger.exe  IOCTL_SERIAL_WAIT_ON_MASK  Serial0
26  0.00107611  SUCCESS
28  0.00097666  SUCCESS
29  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
29  0.0587  SUCCESS
30  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
30  0.0503  SUCCESS
31  0.  TLogger.exe  IOCTL_SERIAL_GET_PROPERTIES  Serial0
31  0.0196  SUCCESS
32  0.  TLogger.exe  IRP_MJ_WRITE  Serial0  Length 1: 00
33  0.  TLogger.exe  IOCTL_SERIAL_SET_WAIT_MASK  Serial0  Mask:
RXCHAR TXEMPTY CTS DSR RLSD BRK ERR RING
33  0.0531  SUCCESS
34  0.  TLogger.exe  IOCTL_SERIAL_WAIT_ON_MASK  Serial0
32  0.00102583  SUCCESS
34  0.00098811  SUCCESS
35  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
35  0.0559  SUCCESS
36  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
36  0.0726  SUCCESS
37  0.  TLogger.exe  IOCTL_SERIAL_GET_COMMSTATUS  Serial0
37  0.0559  SUCCESS
38  0.  TLogger.exe  IOCTL_SERIAL_SET_WAIT_MASK  Serial0  Mask:
RXCHAR TXEMPTY CTS DSR RLSD BRK ERR RING
38  0.1173  SUCCESS
39  0.  TLogger.exe  IOCTL_SERIAL_WAIT_ON_MASK  Serial0
39  0.00934281  SUCCESS
40  0.  TLogger.exe  IOCTL_SERIAL_SET_WAIT_MASK  Serial0  Mask:
RXCHAR TXEMPTY CTS DSR RLSD BRK ERR RING
40  0.0922  SUCCESS
41  0.  TLogger.exe  IOCTL_SERIAL_WAIT_ON_MASK  Serial0
41  0.1034  

Re: pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread Grant Edwards
On 2006-07-24, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Logs of the serial traffic would be helpful.

 Here they are. First a log of the traffic generated by the
 T-logger GUI program, abtained with Portmon.

I try to avoid Windows as much as humanly possible, but one
thing that appears to be different is that Tlogger clears RTS
and your program sets it.  Try clearing RTS in your program
when you set up the serial port.

If clearing RTS doesn't help, I guess I'd try different flow
control settings (try enabling and disabling RTS/CTS flow
control).

Since you're dealing with binary data, make sure that Xon/Xoff
flow control is disabled.

-- 
Grant Edwards   grante Yow!  What's the MATTER
  at   Sid?... Is your BEVERAGE
   visi.comunsatisfactory?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: pyserial to read from DS1615 temperature recorder chip

2006-07-24 Thread Joe Knapka
Grant Edwards wrote:

 On 2006-07-24, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 
 
Logs of the serial traffic would be helpful.

Here they are. First a log of the traffic generated by the
T-logger GUI program, abtained with Portmon.
 
 
 I try to avoid Windows as much as humanly possible, but one
 thing that appears to be different is that Tlogger clears RTS
 and your program sets it.  Try clearing RTS in your program
 when you set up the serial port.
 
 If clearing RTS doesn't help, I guess I'd try different flow
 control settings (try enabling and disabling RTS/CTS flow
 control).
 
 Since you're dealing with binary data, make sure that Xon/Xoff
 flow control is disabled.

It could also be a timing issue or handshaking problem.
Having to write to the chip a byte at a time implies
that it could take it a little while to digest each byte;
longer than the natural character time for the baud rate,
that is. I'm not sure if I'm reading the portmon output
correctly, but it looks like the T-logger program
is waiting for CTS (or possibly some other condition)
before sending each byte. The Python program does not
appear to be doing so, it's just sending the three bytes,
bang bang bang.

-- JK
-- 
http://mail.python.org/mailman/listinfo/python-list