-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I2C writing and writing_bytes cannot seem to write more than 2 bytes of data at a time #27
Comments
I usually see "IOError: [Errno 5] Input/output error" when I'm trying to send to a non-existent address. Have you successfully sent single bytes? |
Hello Nat, Sorry for the delay in responding! I have indeed been able to successfully send single bytes. Dave Date: Sun, 3 Feb 2013 15:02:11 -0800 I usually see "IOError: [Errno 5] Input/output error" when I'm trying to send to a non-existent address. Have you successfully sent single bytes?
|
I've just done a test writing and reading multiple bytes to a 24LC512 eeprom, and everything works as expected. Dave, what is the device you are writing to? |
Sorry for the delay in responding! That's curious - I am writing to an Atmel Atmega168, which has been programmed to send and receive multiple bytes via I2C. I've tested the Atmega168 and found it to work with other devices. But when I tried to write to it with the quick2wire api, I couldn't get more than 2 bytes to go across at a time. I confirmed this with an I2C protocl analyzer (a gabotronics xprotolab). I wonder what is different? I'm tempted to send one of these to you to see if you can get it to work. The code I have running on the Atmega168 is on my other computer -I'll get it out to you as an attachment if you want. Cheers, Date: Sun, 17 Feb 2013 07:25:06 -0800 I've just done a test writing and reading multiple bytes to a 24LC512 eeprom, and everything works as expected. Dave, what is the device you are writing to?
|
Thanks for the extra background. A copy of the 168 code would be useful. As it happens, some of the code I need to work on today involves sending I'm sorry you're experiencing problems, but this kind of user feedback is I've copied this to our user group, just in case someone else has On 26 February 2013 00:53, davec2 [email protected] wrote:
http://quick2wire.com safe, simple connection to your Raspberry Pi |
Sorry for taking this long to get back to you - it has been a rather strange few days. So anyway, I have attached the code which I programmed onto the Atmel AVR ATMEGA168 processor. The code reflects the send-one-byte-at-a-time nature that I discovered when running the python module on the RPi. However, I direct your attention to the function handleI2C() - in it is a case statement which first tests for TW_STATUS equaling 0x60; the condition on r_index >= BUFLEN_RECV should allow the Atmega to return a NACK; this should then allow the I2C master to send more bytes. For whatever reason, I could not get this to work on the RPi with the quick2wire module, most likely due to my feeble programming skills more than anything else. I would be most grateful if you could see if you can get it to work. I've written this code so that one byte per I2C write can be received. In order to return it to it original state, where it will try to receive 5 bytes at a go, do the following: I hope this helps. I am quite interested in hearing how well it works (or doesn't)! Dave Thanks for the extra background. A copy of the 168 code would be useful. As it happens, some of the code I need to work on today involves sending I2C data from a Pi to an arduino clone. So far I've been sending single bytes but today I'll try more than one. I'll capture bus activity with the Open Workbench Logic Sniffer and report results. I'm sorry you're experiencing problems, but this kind of user feedback is really valuable. Either our code is doing something wrong, (in which case we need to find and fix it), or you are (in which case our documentation is defective, and we need to fix that). I've copied this to our user group, just in case someone else has similar problems or has an idea of what's going wrong. On 26 February 2013 00:53, davec2 [email protected] wrote:
http://quick2wire.com safe, simple connection to your Raspberry Pi — #define SET(x,y) (x|=(1<<y)) #define sbi(x,y) x |= _BV(y) //set bit #define F_CPU 8000000UL #include <util/delay.h> #define BUFLEN_TRAN 3 //variable to indicate if something went horribly wrong int timer0_overflow_count; //globals for our input packet char new_cmd = 0; //setup the I2C hardware to ACK the next transmission // ****************************** /*SIGNAL(SIG_OVERFLOW0) */ ISR(TIMER0_OVF_vect) ISR(TIMER1_COMPA_vect) } ISR(TIMER1_OVF_vect) } //
} void delayms( uint16_t millis ) { void handleI2C(){ int true_convert(char dur_1, char dur_0) actual = dur_1*100 + dur_0; // maybe could do some limit checking here or accept other conversions? } //---------------MAIN--------------------------------------------- //DDRD = 0b10010111; // setup the PWM counters
// timer 0 is used for the delayms function
sei(); while(1){ if (new_cmd == 1)
} |
I think this is an issue. It caught me by surprise, but sometimes that doesn't take much. I hope this is the correct place for this topic.
I'm running Rasparian wheezy with kernel 3.2.27 on a Rev 2 RPi, and am attempting to write more than 2 bytes to an I2C slave device. I did the following in python3:
import quick2wire.i2c as i2c
address = 0x01
with i2c.I2CMaster() as bus:
bus.transaction(i2c.writing_bytes(address, 0x01,0x02))
I get the following error:
File "/home/pi/quick2wire-python-api-master/quick2wire/i2c.py", line 74, in transaction
ioctl(self.fd, I2C_RDWR, ioctl_arg)
IOError: [Errno 5] Input/output error
I have an I2C sniffer on the SDA and SCL pins - I see the two bytes on the line, but I still get this error.
Further, if I try to send more than 2 bytes, I only ever see just the first two bytes on the I2C bus, and I get the same error as above.
I was under the impression that I could send any length of byte values using the i2c.py methods?
The text was updated successfully, but these errors were encountered: