Changeset 4450
- Timestamp:
- 06/16/07 16:01:05 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/prog/py-smbus/smbusmodule.c
r4445 r4450 1 1 /* 2 2 * smbusmodule.c - Python bindings for Linux SMBus access through i2c-dev 3 * Copyright (C) 2005 ,2006Mark M. Hoffman <mhoffman@lightlink.com>3 * Copyright (C) 2005-2007 Mark M. Hoffman <mhoffman@lightlink.com> 4 4 * 5 5 * This program is free software; you can redistribute it and/or modify … … 24 24 #include <linux/i2c-dev.h> 25 25 26 /* 27 ** These are required to build this module against Linux older than 2.6.23. 28 */ 29 #ifndef I2C_SMBUS_I2C_BLOCK_BROKEN 30 #undef I2C_SMBUS_I2C_BLOCK_DATA 31 #define I2C_SMBUS_I2C_BLOCK_BROKEN 6 32 #define I2C_SMBUS_I2C_BLOCK_DATA 8 33 #endif 34 26 35 PyDoc_STRVAR(SMBus_module_doc, 27 36 "This module defines an object type that allows SMBus transactions\n" … … 487 496 488 497 PyDoc_STRVAR(SMBus_read_i2c_block_data_doc, 489 "read_i2c_block_data(addr, cmd ) -> results\n\n"498 "read_i2c_block_data(addr, cmd, len=32) -> results\n\n" 490 499 "Perform I2C Block Read transaction.\n"); 491 500 … … 493 502 SMBus_read_i2c_block_data(SMBus *self, PyObject *args) 494 503 { 495 int addr, cmd ;504 int addr, cmd, len=32; 496 505 union i2c_smbus_data data; 497 506 498 if (!PyArg_ParseTuple(args, "ii:read_i2c_block_data", &addr, &cmd)) 499 return NULL; 500 501 SMBus_SET_ADDR(self, addr); 502 507 if (!PyArg_ParseTuple(args, "ii|i:read_i2c_block_data", &addr, &cmd, 508 &len)) 509 return NULL; 510 511 SMBus_SET_ADDR(self, addr); 512 513 data.block[0] = len; 503 514 /* save a bit of code by calling the access function directly */ 504 515 if (i2c_smbus_access(self->fd, I2C_SMBUS_READ, (__u8)cmd, 516 len = 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN: 505 517 I2C_SMBUS_I2C_BLOCK_DATA, &data)) { 506 518 PyErr_SetFromErrno(PyExc_IOError); … … 530 542 /* save a bit of code by calling the access function directly */ 531 543 if (i2c_smbus_access(self->fd, I2C_SMBUS_WRITE, (__u8)cmd, 532 I2C_SMBUS_I2C_BLOCK_ DATA, &data)) {544 I2C_SMBUS_I2C_BLOCK_BROKEN, &data)) { 533 545 PyErr_SetFromErrno(PyExc_IOError); 534 546 return NULL;
