[Elphel-support] channel switching and exposure question
Andreas Bean
office at beanbox.com
Mon Sep 6 13:22:32 PDT 2010
Andrey, Oleg,
Yes I have an older version of 359.bit because in some newer versions
the combining mode didn't work. I haven't tried the latest version.
In my version reg_write.php is called with the values 835 and 02 and
does switch the sensor.
fpcf does not. I still don't understand why. Anyway, I will update and
try the commands mentioned below.
Should the combining/alternating modes work in the current version?
Andrey, nor fpcf or reg_write.php follow the safety procedure you
mentioned in your last mail, do they?
If I understand you right then placing i²c commands through the
sequencer is the safer option. How can I do that from c? Can you tell me
a starting point for further code investigation?
Andreas
Oleg K Dzhimiev schrieb:
> Adreas,
>
> Sorry, I didn't tell you - I changed reg addresses in 10359 a while
> ago (in Jan-Feb) - you can find new addresses here:
> http://wiki.elphel.com/index.php?title=Talk:10359
> I will update this page today-tomorrow - there're small updates - as
> for direct channel switching the info is correct:
>
> fpcf -i2cw16 806 1
>
> fpcf -i2cw16 806 2
>
> fpcf -i2cw16 806 3
>
>
> Best regards,
> Oleg
>
> On 6 September 2010 04:59, Andreas Bean <office at beanbox.com
> <mailto:office at beanbox.com>> wrote:
>
> Hi Andrey,
>
> Thank you for your answer. See the code snippets below. Both open
> the device /dev/xi2c16.
> reg_write.php is called with the parameters 0x835 0x2 to switch to
> channel 2.
> Why doesn't the command
>
> fpcf -i2cw16 0x835 0x02
>
> do the same? Both write to /dev/xi2c16
> I prefer to set the values from c, directly. Thank you for the
> info about the possibility of an inconsistency on driver level.
> But I don't think that this is the problem here.
>
> Do you know why the two code snippets don't do the same?
>
> Andreas
>
> ---------------------------- fpcf.c -------------------------------
> shft=-1;
> if (strcasecmp(argv[1], "-i2cw8") ==0) shft=0;
> if (strcasecmp(argv[1], "-i2cw16") ==0) shft=1;
> if (shft>=0) { // write i2c bus0
> if (argc<3) {printf("Need I2C address (hex) to write:
> register address + 256* (slave address>>1)\r\n");return -1;}
> if (argc<4) {printf("Need data (hex) to write to i2c bus
> 0\r\n");return -1;}
> sa= strtol (argv[2],&cp,16);
> uld=strtol (argv[3],&cp,16);
> if (shft==1) {
> if ((devfd = open("/dev/xi2c16", O_RDWR))<0)
> {printf("error opening /dev/xi2c16\r\n"); return -1;}
> uld= ((uld >>8) & 0xff) | ((uld <<8) & 0xff00);
> } else {
> if ((devfd = open("/dev/xi2c8", O_RDWR))<0)
> {printf("error opening /dev/xi2c8\r\n"); return -1;}
> }
> if ((res=lseek(devfd,sa<<shft,0))<0) {
> printf("lseek failed, returned %d\n",res);
> close (devfd);
> return -1;
> }
> if ((res=write(devfd,&uld,1<<shft))<(1<<shft)) {
> printf("write failed, returned %d, expected - %d\n",res,
> (1<<shft));
> close (devfd);
> return -1;
> }
> close (devfd);
> return 0;
> }
> ---------------------------- reg_write.php -------------------------
> function send_i2c_4($a,$d) {
> $i2c = fopen('/dev/xi2c16', 'w');
> fseek ($i2c, 2*$a) ;
> if ($w==1) $res=fwrite($i2c, chr ($d));
> else {
> $res=fwrite($i2c, chr (floor($d/(256*256*256))).chr (($d -
> 256*256*256*floor($d/(256*256*256)))/(256*256)).chr (($d -
> 256*256*floor($d/(256*256)))/256).chr ($d - 256*floor($d/(256))) );
> printf("v1=%d\n",floor($d/(256*256*256)));
> printf("v2=%d\n",($d -
> 256*256*256*floor($d/(256*256*256)))/(256*256));
> printf("v3=%d\n",($d - 256*256*floor($d/(256*256)))/256);
> printf("v4=%d\n",$d - 256*floor($d/(256)));
>
> }
>
> fclose($i2c);
> return $res;
> }
>
>
> _______________________________________________
> Support-list mailing list
> Support-list at support.elphel.com
> <mailto:Support-list at support.elphel.com>
> http://support.elphel.com/mailman/listinfo/support-list_support.elphel.com
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: office.vcf
Type: text/x-vcard
Size: 230 bytes
Desc: not available
URL: <http://support.elphel.com/pipermail/support-list_support.elphel.com/attachments/20100906/255e8346/attachment.vcf>
More information about the Support-list
mailing list