uisp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Uisp-dev] The many cables


From: Joakim Arfvidsson
Subject: Re: [Uisp-dev] The many cables
Date: Wed, 20 Oct 2004 22:35:16 +0200

Avrdude already does something like that via a monster config file.

Are you talking about parsing a config file?

I'm not a a big fan of adding yet another config file to the user's
system.

The cable descriptions should live with the app, with the option of specifying another cable file if you have a special cable.


The file would have to store the usual pins, if they are inverted or
not, and if there's any special behaviour going on.

It's quite easy to know if a pin is control, status or data.  We don't
need to have the long case that does always the same, just a case for
the type of pin... For example:

void
TDAPA::OutReset(int b)
{
(...)
  switch (rst_type)
  {
  case CONTROL:
    if (b) par_ctrl |= rst_pin; else par_ctrl &= ~rst_pin;
    ParportWriteCtrl();
    break;

  case DATA:
    if (b) par_data |= rst_pin; else par_data &= ~rst_pin;
    ParportWriteData();
    break;
  }
(...)
}

This is just for parallel, something like that could be done for
serial as well.

What do you think?

I've thought about this in the past but never had the time to move
forward on it...

The switch statements could very easily be replaced with a class
structure. Setup a base class and have each cable type inherit that and
then tweak what it needs. Then each of the many switch statements in the
code is just replaced by a call the classes method to handle that
operation.

I'm not vetoing reading a file you are suggesting, just giving an
alternative.

A class structure with inheritance seems like the obvious choice! Then there should be one class "general parallell port cable" that fetches its pin numbers from a data file.

Joakim

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]