-
Notifications
You must be signed in to change notification settings - Fork 4
Updated i2c pipe data transfer #17
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what functionality these changes add. If you use the 'pipe'
option, it looks like you never receive data from these functions, it just goes to a time.sleep
and ends. @cnbecks Could you provide some context as to how these functions are being used that requires the time.sleep
with no data?
if data_transfer.lower() == 'pipe': | ||
# this does not take care of the FIFO reset | ||
# wait so next data is ready, then continue | ||
time.sleep(0.01) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that if data_transfer
is set to 'pipe'
, then no data is returned from this function. Why is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ajstros sorry for the confusion! Currently there are separate methods that are being used to read out and clear the pipe (read_i2c_pipe
and reset_i2c_fifo
, which are both located in the TMF8801_sandbox.py
file), the reason for the change in I2CController.py
is to avoid reading data through the wire in the process of reading it through the pipe, which is why there is only a time.sleep
call and nothing else. The time.sleep
is included because without it the pipe is occasionally read before being filled, creating incomplete or corrupted histograms.
Here are the methods I mentioned if you want to take a look! And definitely let me know if you have more questions.
def read_i2c_pipe(tof_dev, data_len=256):
return tof_dev.fpga.read_pipe_out(tof_dev.endpoints['PIPE_OUT'].address,
data_len)
def reset_i2c_fifo(tof_dev):
tof_dev.fpga.xem.ActivateTriggerIn(
tof_dev.endpoints['FIFO_RESET'].address, tof_dev.endpoints['FIFO_RESET'].bit_index_low) # High and low bit indexes are the same for the trigger because it is 1 bit wide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last couple changes I committed add the FIFO reset and PIPE read functionality into i2c_receive
so the function works on its own and remains general enough that future peripherals could also use this I2C pipe data functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cnbecks I almost forgot but the added data_transfer
parameter in i2c_receive
and i2c_read_long
should be added to each of their docstrings as well. Something like this for example for i2c_receive
.
def i2c_receive(self, data_length, data_transfer='wire'):
"""Take in data from the SCL and SDA lines.
Parameters
----------
data_length : int
Number of bytes expected to receive.
data_transfer : str
The form of the data transfer. Either 'wire' and 'pipe'. Defaults to 'wire'.
Returns
-------
data or buf, e : list or bytearray, int
The data or a bytearray and error code, depending on whether data_transfer was 'wire' or 'pipe'.
"""
Could you copy this in and add something similar for data_transfer
to the i2c_read_long
docstring?
@cnbecks I think we can merge this now. I believe everything is set up so you should be able to merge (please use the "Squash and merge" option for this) so I'll let you do it. |
@Ajstros hopefully that worked properly. Let me know if something went awry! |
@cnbecks Looks good, thanks! |
Altered the i2c_read_long and i2c_receive methods in order to read in sensor data through the FIFO pipe without also reading it in through the wire. Pipe data transfer now works and is more time efficient. Summary of the changes: