1
0
mirror of https://github.com/richardghirst/PiBits.git synced 2025-02-20 14:54:14 +01:00

Add crude 'written_data' array so dev_read simply echos verbatim what was written to dev_write without probing the actual DMA control block data. This gives no clue as to whether the DMA control bloack has been programmed but does mean that Richard's control code - which has a special case for delay=0 - does not require changing. Next steps are to have an array per-process.

This commit is contained in:
Robin Mallinson 2012-11-18 14:09:45 +00:00
parent 94c2aab61b
commit 4b87d814df
2 changed files with 5 additions and 5 deletions

View File

@ -321,6 +321,8 @@ static int dev_open(struct inode *inod,struct file *fil)
return 0;
}
static int written_data[NUM_SERVOS] = { 0 };
static ssize_t dev_read(struct file *filp,char *buf,size_t count,loff_t *f_pos)
{
ssize_t bytesPrinted = 0;
@ -334,13 +336,10 @@ static ssize_t dev_read(struct file *filp,char *buf,size_t count,loff_t *f_pos)
// Get fresh data
for (servo=0, idx=0; servo < NUM_SERVOS; ++servo)
{
if (wait_for_servo(servo))
return -EINTR;
idx += snprintf(returnedData+idx, sizeof(returnedData)-idx,
"%i %lu\n",
"%i %i\n",
servo,
ctl->cb[servo*4+1].length / sizeof(uint32_t)
written_data[servo]
);
}
}
@ -411,6 +410,7 @@ static ssize_t dev_write(struct file *filp,const char *buf,size_t count,loff_t *
ctl->cb[servo*4+1].length = cnt * sizeof(uint32_t);
ctl->cb[servo*4+3].length = (cycle_ticks / 8 - cnt) * sizeof(uint32_t);
}
written_data[servo] = cnt; // Record data for use by dev_read
local_irq_enable();
return count;

Binary file not shown.