Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2010-01-11 Thread Alexis Berlemont
Hi,

On Mon, Jan 11, 2010 at 5:08 PM, Alessio Margan @ IIT
alessio.mar...@iit.it wrote:
 Hi,

 I try to configure sensoray counters to generate PWM signal

 #define SUBD_CNT 0
 #define SUBD_AI 1
 #define SUBD_AO 2
 #define SUBD_DIO 3

 insn.type = A4L_INSN_CONFIG;
 insn.idx_subd = SUBD_COUNTER;
 insn.chan_desc = CHAN(channel);
 insn.data_size = sizeof(dataC) / sizeof(dataC[0]);
 insn.data = data;
 data[0] = A4L_INSN_CONFIG_GPCT_PULSE_TRAIN_GENERATOR;
 data[1] = cmReg.value;
 data[2] = down_ticks;
 data[3] = up_ticks;

 ret = a4l_snd_insn(dsc, insn);

 in a4l_do_insn the subdevice is check in this way but the test for
 counter, and I think also for dio, fails due
 to A4L_SUBD_MASK_SPECIAL bit

 #define A4L_SUBD_UNUSED (A4L_SUBD_MASK_SPECIAL|0x1)
 #define A4L_SUBD_COUNTER (A4L_SUBD_MASK_SPECIAL|0x40)
 #define A4L_SUBD_DIO (A4L_SUBD_MASK_SPECIAL|0x20)

 /* Checks the subdevice's characteristics */
 if ((subd-flags  A4L_SUBD_UNUSED) != 0) {
 __a4l_err(a4l_do_insn: wrong subdevice selected 0x%X\n,subd-flags);
 return -EINVAL;
 }

 there is something wrong or I miss something ?
You miss nothing. There was a bug in the subdevice's flags checking line:
The problem is here: if ((subd-flags  A4L_SUBD_UNUSED) != 0) {

I fixed it in my git repo one week ago.

Either you clone my git repot or you wait for the pull request I will
make tonight.

Regards,


 TIA

 Alessio


 --

 ISTITUTO ITALIANO
 DI TECNOLOGIA

 Alessio Margan
 /Senior Technician/
 mail me mailto:alessio.mar...@iit.it

 Via Morego, 30 16163 Genova
 http://maps.google.com/maps?f=qhl=engeocode=q=via+morego,+30+genovasll=37.0625,-95.677068sspn=85.420533,191.601563ie=UTF8ll=44.474913,8.907037spn=0.004685,0.011652t=hz=17iwloc=addr

 www.iit.it http://www.iit.it

 *Legal Disclaimer*
 This electronic message contains information that is confidential. The
 information is intended for the use of the addressee only. If you are
 not the addressee we would appreciate your notification in this respect.
 Please note that any disclosure, copy, distribution or use of the
 contents of this message is prohibited and may be unlawful. We have
 taken every reasonable precaution to ensure that any kind of attachment
 to this e-mail has been swept for viruses. However, we cannot accept
 liability for any damage sustained as a result of software viruses and
 would advise you to carry out your own virus checks before opening any
 attachment.
 *Avvertenza legale*
 Questo messaggio Email contiene informazioni confidenziali riservate ai
 soli destinatari. Qualora veniate in possesso di tali informazioni senza
 essere definito come destinatario vi reghiamo di leggere le seguenti
 note. Ogni apertura, copia, distribuzione del contenuto del messaggio e
 dei suoi allegati è proibito e potrebbe violare le presenti leggi.
 Abbiamo attivato ogni possibile e ragionevole precauzione per assicurare
 che gli allegati non contengano virus. Comunque non assumeremo alcuna
 responsabilità per ogni eventuale danno causato da virus software e
 simili in quanto è onere del destinatario verificarne l’assenza in ogni
 allegato attuando propri indipendenti controlli.


 ___
 Xenomai-core mailing list
 Xenomai-core@gna.org
 https://mail.gna.org/listinfo/xenomai-core


Alexis.

___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2010-01-07 Thread Alexis Berlemont
Hi,

Alessio Margan @ IIT wrote:
 Hi,
 
 I've got a doubt about s526 driver on reading analog input.
 
 I read analog data in this way
 
 sampl_t data;
 a4l_insn_t insn_tab = {
 .type = A4L_INSN_READ,
 .idx_subd = idx_subd,
 .chan_desc = CHAN(idx_chan),
 .data_size = sizeof(data),
 .data = data};
 
 /* Sends the read instruction to the Analogy layer */
 ret = a4l_snd_insn(dsc, insn_tab);
 
 on driver side data_size is the number of samples not the nr of byte to 
 read,
 the driver expect data_size to be the number of samples and data to be a 
 vector of samples
You are right. There is a bug in the driver. The field data_size is not 
the acquisition count but the size of all the acquisitions in bytes.

So we should see:
for (n = 0; n  insn-data_size / sizeof(uint16_t); n++) {

I will fix it tonight.

 
 uint16_t *data = (uint16_t *)insn-data;
 
 /* convert n samples */
 for (n = 0; n  insn-data_size; n++) {
 /* trigger conversion */
 outw(value, ADDR_REG(REG_ADC));
 a4l_info(dev, s526_ai_rinsn: Wrote 0x%04x to ADC\n, value);
 a4l_info(dev, s526_ai_rinsn: ADC reg=0x%04x\n, inw(ADDR_REG(REG_ADC)));
 
 #define TIMEOUT 100
 
 /* wait for conversion to end */
 for (i = 0; i  TIMEOUT; i++) {
 status = inw(ADDR_REG(REG_ISR));
 if (status  ISR_ADC_DONE) {
 outw(ISR_ADC_DONE, ADDR_REG(REG_ISR));
 break;
 }
 }
 if (i == TIMEOUT) {
 a4l_warn(dev, s526_ai_rinsn: ADC(0x%04x) timeout\n, 
 inw(ADDR_REG(REG_ISR)));
 return -ETIMEDOUT;
 }
 
 /* read data */
 d = inw(ADDR_REG(REG_ADD));
 a4l_info(dev, s526_ai_rinsn: AI[%d]=0x%04x\n, n, (unsigned short)(d  
 0x));
 
 /* munge data */
 data[n] = d ^ 0x8000;
 }
 
 TIA
 
 Alessio
 

Alexis.

___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2010-01-04 Thread Alessio Margan @ IIT
Hi,

 The irq parameter is not used. It's not used in comedi either.
 For the io_port, the command analogy_config analogy0 analogy_s526 0xdc0 
 works for me...

   
not for me ... driver arg 0xdc0 when red by sscanf(opts, %u,
res[(*nb) - 1]) in analogy_config.c in function compute_opts is set to
0 due to %u
if I use the decimal value of ioport it works ... analogy_config
analogy0 analogy_s526 3520
 Did you try to acquire data?
   
I try with insn_read command find in src/utils/analogy but seems that
subdevice should have commands enabled subd-flags |= A4L_SUBD_CMD;

Alessio

-- 

ISTITUTO ITALIANO
DI TECNOLOGIA

Alessio Margan
/Senior Technician/
mail me mailto:alessio.mar...@iit.it

Via Morego, 30 16163 Genova
http://maps.google.com/maps?f=qhl=engeocode=q=via+morego,+30+genovasll=37.0625,-95.677068sspn=85.420533,191.601563ie=UTF8ll=44.474913,8.907037spn=0.004685,0.011652t=hz=17iwloc=addr

www.iit.it http://www.iit.it

*Legal Disclaimer*
This electronic message contains information that is confidential. The
information is intended for the use of the addressee only. If you are
not the addressee we would appreciate your notification in this respect.
Please note that any disclosure, copy, distribution or use of the
contents of this message is prohibited and may be unlawful. We have
taken every reasonable precaution to ensure that any kind of attachment
to this e-mail has been swept for viruses. However, we cannot accept
liability for any damage sustained as a result of software viruses and
would advise you to carry out your own virus checks before opening any
attachment.
*Avvertenza legale*
Questo messaggio Email contiene informazioni confidenziali riservate ai
soli destinatari. Qualora veniate in possesso di tali informazioni senza
essere definito come destinatario vi reghiamo di leggere le seguenti
note. Ogni apertura, copia, distribuzione del contenuto del messaggio e
dei suoi allegati è proibito e potrebbe violare le presenti leggi.
Abbiamo attivato ogni possibile e ragionevole precauzione per assicurare
che gli allegati non contengano virus. Comunque non assumeremo alcuna
responsabilità per ogni eventuale danno causato da virus software e
simili in quanto è onere del destinatario verificarne l’assenza in ogni
allegato attuando propri indipendenti controlli.



___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2010-01-04 Thread Alexis Berlemont
Alessio Margan @ IIT wrote:
 Hi,
 
 The irq parameter is not used. It's not used in comedi either.
 For the io_port, the command analogy_config analogy0 analogy_s526 0xdc0 
 works for me...

   
 not for me ... driver arg 0xdc0 when red by sscanf(opts, %u,
 res[(*nb) - 1]) in analogy_config.c in function compute_opts is set to
 0 due to %u
 if I use the decimal value of ioport it works ... analogy_config
 analogy0 analogy_s526 3520

It seems the version you are using is not up to date, this bug was fixed
two months ago:

commit 01bcfd898555425e96350b306155cba429a65539
Author: Alexis Berlemont alexis.berlem...@gmail.com
Date: Sun Nov 8 02:10:20 2009 +0100

analogy: fix a bug in the attach procedure

The options to be sent to the driver at attach time were badly handled
if the values were hexadecimal-based.

 Did you try to acquire data?
   
 I try with insn_read command find in src/utils/analogy but seems that
 subdevice should have commands enabled subd-flags |= A4L_SUBD_CMD;
 
 Alessio
 
Regards,

Alexis.


___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2010-01-02 Thread Simon Boulay
Hi,

On 12/30/2009 03:53 PM, Alessio Margan @ IIT wrote:
 Hi,

 I start test the sensoray driver.
Thank you!

 I've got problem with analogy_config :
 1) it seems that board_name as defined have some problem, changed to
 a4l_s526 seems better

  #define BOARD_NAME Sensoray Model 526
  ...
  .board_name = BOARD_NAME
It works with quotes but it's neither handy nor consistent. It'll be 
renamed to analogy_s526.

 2) I should be able to set as parameters io_port and irq (seems not
 used), using comedi I do comedi_config  /dev/comedi0 s526 0xDC0,0x7
 for the moment I set S526_DEFAULT_ADDRESS to my configuration
 with this modifications seems to work.
The irq parameter is not used. It's not used in comedi either.
For the io_port, the command analogy_config analogy0 analogy_s526 0xdc0 
works for me...

Did you try to acquire data?

Simon.

 analogy_config -v analogy0 a4l_s526

 cat /proc/analogy/drivers
 --  Analogy drivers --
 | idx | driver name
 |  00 | a4l_s526

 cat /proc/analogy/devices
 --  Analogy devices --
 | idx | status | driver
 |  00 | Linked | a4l_s526
 |  01 | Unused | No driver
 |  02 | Unused | No driver
 |  03 | Unused | No driver
 |  04 | Unused | No driver
 |  05 | Unused | No driver
 |  06 | Unused | No driver
 |  07 | Unused | No driver
 |  08 | Unused | No driver
 |  09 | Unused | No driver

 cat /proc/analogy/00-a4l_s526
 --  Subdevices --
 | idx | type
 |  00 | Counter subdevice
 |  01 | Analog input subdevice
 |  02 | Analog output subdevice
 |  03 | Digital input/output subdevice

 Alessio



___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2009-12-29 Thread Alessio Margan @ IIT
Simon Boulay wrote:
 Alessio was interested by this driver; Alessio, the drivers is yours as soon
 as it is available in my git repository.
 
 I'll be pleased to help anybody who can test the driver.

   
Hi,
good news ... I'll test the patch asap.
Thank you very much for your help.

Alessio

-- 

ISTITUTO ITALIANO
DI TECNOLOGIA

Alessio Margan
/Senior Technician/
mail me mailto:alessio.mar...@iit.it

Via Morego, 30 16163 Genova 
http://maps.google.com/maps?f=qhl=engeocode=q=via+morego,+30+genovasll=37.0625,-95.677068sspn=85.420533,191.601563ie=UTF8ll=44.474913,8.907037spn=0.004685,0.011652t=hz=17iwloc=addr

www.iit.it http://www.iit.it

*Legal Disclaimer*
This electronic message contains information that is confidential. The 
information is intended for the use of the addressee only. If you are 
not the addressee we would appreciate your notification in this respect. 
Please note that any disclosure, copy, distribution or use of the 
contents of this message is prohibited and may be unlawful. We have 
taken every reasonable precaution to ensure that any kind of attachment 
to this e-mail has been swept for viruses. However, we cannot accept 
liability for any damage sustained as a result of software viruses and 
would advise you to carry out your own virus checks before opening any 
attachment. 
*Avvertenza legale*
Questo messaggio Email contiene informazioni confidenziali riservate ai 
soli destinatari. Qualora  veniate in possesso di tali informazioni 
senza essere definito come destinatario vi reghiamo di leggere le 
seguenti note. Ogni apertura, copia, distribuzione del contenuto del 
messaggio e dei suoi allegati è proibito e potrebbe violare le presenti 
leggi. Abbiamo attivato ogni possibile e ragionevole precauzione per 
assicurare che gli allegati non contengano virus. Comunque non 
assumeremo alcuna responsabilità per ogni eventuale danno causato da 
virus software e simili in quanto è onere del destinatario verificarne 
l’assenza in ogni allegato attuando propri indipendenti controlli.


___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2009-12-28 Thread Alexis Berlemont
Hi Simon,

Simon Boulay wrote:
  Hi,
 
  Here is a patch which adds the support of the Sensoray Model 526 board
  to analogy.

Great ! I had a look at the code, that is fine for me. I just have few
remarks:
- some printk were left commented in the original comedi driver, you
correctly translated them into a4l_info; however, could you use a4l_dbg
instead and remove the comments ?
- the sources of the original driver contain many areas of commented
code and #if 0 #else #endif directives. In order to keep coherency
with the original driver, I think the import of the driver should be
done as it is; nonetheless, the second step would be to clean it inside
the git repository.

I think it is wise to wait for the release of 2.5 before integrating it. 
It will be made available in Xenomai 2.5.1.

  The driver compiles against head but have not been tested on real 
hardware yet.
Alessio was interested by this driver; Alessio, the driver is yours as
soon as it is available in my git repository.

  It has been ported from comedi (staging version) and should work as 
in comedi:
  - Encoder works
  - Analog input works
  - Analog output works
  - PWM output works
  - Commands are not supported yet.
 
  Regards,
Many thanks for your work !

  Simon.
 
Alexis.



___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core


Re: [Xenomai-core] [PATCH] Sensoray 526 analogy driver

2009-12-28 Thread Simon Boulay
On Mon, Dec 28, 2009 at 9:40 PM, Alexis Berlemont
alexis.berlem...@gmail.com wrote:
 Hi Simon,

 Simon Boulay wrote:

 Hi,

 Here is a patch which adds the support of the Sensoray Model 526 board
 to analogy.

 Great ! I had a look at the code, that is fine for me. I just have few
 remarks:
 - some printk were left commented in the original comedi driver, you
 correctly translated them into a4l_info; however, could you use a4l_dbg
 instead and remove the comments ?
Yes.

 - the sources of the original driver contain many areas of commented code
 and #if 0 #else #endif directives. In order to keep coherency with the
 original driver, I think the import of the driver should be done as it is;
 nonetheless, the second step would be to clean it inside  the git
 repository.
I totally agree. The #if 0 #else #endif directives are mainly
documentation or examples. I don't know if they are useful anymore but
I preferred to let them in place for first tests.
I'll send you patches when the driver will be available in your git repository.
There are certainly things to add or optimize but I tried to not
divert too much from the original driver for the beginning.
If you think that's not the right way of doing, tell me. I plan to
publish the jr3 driver port this week. The original code is far more
clean but I'll appreciate your advices.

 I think it is wise to wait for the release of 2.5 before integrating it. It
 will be made available in Xenomai 2.5.1.
ok.

 The driver compiles against head but have not been tested on real hardware
 yet.

 Alessio was interested by this driver; Alessio, the drivers is yours as soon
 as it is available in my git repository.
I'll be pleased to help anybody who can test the driver.

 It has been ported from comedi (staging version) and should work as in
 comedi:
 - Encoder works
 - Analog input works
 - Analog output works
 - PWM output works
 - Commands are not supported yet.

 Regards,

 Many thanks for your work !
Your welcome. Let see if it works...


 Simon.

 Alexis.


___
Xenomai-core mailing list
Xenomai-core@gna.org
https://mail.gna.org/listinfo/xenomai-core