Need help programming a prism card

jbarnett at coleinnovations.com jbarnett at coleinnovations.com
Mon Dec 18 16:04:39 EST 2006


Hi,
Iv'e been working on this problem for some time now, and I am in need
for some much needed help. Let me first describe what I am trying to
accomplish, I current have a Intersil PRISM 2 (802.11b) PCMCIA wireless

card; the card has three LEDs on the top part of the card. One of these


LEDs is the power LED, which lights green when the card is turned on.


The PRISM 2 wireless card came with the old linux-wlan-ng 2.0 drivers;
very out of date, and it also came with a tiny piece of software. This
piece of software has a couple of functions that are used to control
the wireless card; but the main function that I am interested in, is
the function that turns the card on, called "cardon". When I properly
configure the card using the linux-wlan-ng tools, and then run,
"./cardon wlan0". The power LED light turns green, and I then run
"tcpdump -x -X -s 2346 -vvv -i wlan0", which displays the expected
results to standard out.


My goal is to make this card work with the hostap-driver-0.4.9; which
is the newest drivers for the PRISM chipset. I am currently running
slackware 10.2 with the 2.4.31 kernel. The reason I want my wireless
card to work with the hostAP drivers is because I can use programs like


iwconfig, iwpriv, etc.


Now, when I insert the PRISM 2 wireless card into my PCMCIA slot, with
the hostAP drivers, the lights on the card flash; twice, then they go
blank. Now when I go and run "./cardon wlan0" the card should turn on,
but it doesn't because the "cardon" program is meant to communicate
with the linux-wlan-ng drivers; not the hostAP drivers.


I started to develope a new application that will turn the card on, and


will work with the hostAP driver. I beleive I am using the correct
value for the second aurgument to the ioctl call. I am not very good at


programming low level devices, but what I beleive is going on, is the
hex value gets sent to the wireless card which turns the card on; the
hex number is specific to the card. Once the ioctl is sent over the
socket; the card changes certain values in a structure, known as
comm_t. Im getting return values, from the comm_t struct, but not the
correct values.


The correct values that comm_t is suppose to return are..
NOTE: This is being ran using the linux-wlan-ng drivers


cmd: 24 = 0x11
param0:  0 = 0x00
param1:  0 = 0x00
param2:  0 = 0x00
response0:  0 = 0x00
response1:  0 = 0x00
response2: 24 = 0x11
status:     1 = 0x01


The incorrect values for comm_t are ..
NOTE: This is being ran using the hostAP drivers, these values value
sometimes..


cmd: 226 = 0xE2
param0: 101 = 0x65
param1: 230 = 0xE6
param2: 116 = 0x74
response0: 232 = 0xE8
response1: 105 = 0x69
response2: 238 = 0xEE
status:    114 = 0x72


Here is the code that I currently have been working on, this compiles
fine, but im just not getting the green LED light to turn on..


//----------------------------------------cardon.h-------------------------­­--------------------


#define  ERR          1      /*error condition */
#define  MSIZE        4000        /* The message size */
#define  NAMELEN     16          /* length of device name */
#define  TURNCARDON    0x11        /* Turn card on command */


typedef char format_t [10];


typedef struct commt
{
   char header[32]                       __attribute__ ((packed));
   unsigned short cmd                __attribute__ ((packed));  /* The
command */
   format_t format1                       __attribute__ ((packed));
/*params for cmd*/
   unsigned short param0             __attribute__ ((packed));  /*
param0*/
   format_t format2                       __attribute__ ((packed));
   unsigned short param1             __attribute__ ((packed));  /*
param1*/
   format_t format3                       __attribute__ ((packed));
   unsigned short param2             __attribute__ ((packed));  /*
param2*/
   format_t format4                       __attribute__ ((packed));
/*response for cmd*/
   unsigned short response0          __attribute__ ((packed));  /*
response0 */
   format_t format5                       __attribute__ ((packed));
   unsigned short response1          __attribute__ ((packed));  /*
response1 */
   format_t format6                       __attribute__ ((packed));
   unsigned short response2          __attribute__ ((packed));  /*
response2 */
   format_t format7                       __attribute__ ((packed));
   unsigned short stat             __attribute__ ((packed));  /* The
status of the command */



} __attribute__ ((packed)) comm_t;


#define REQUESTLOWLEVEL  {0x00, 0x00, 0xc5, 0x41, \
                          0x00, 0x00, 0x00, 0x00, \
                          0x04, 0x00, 0x00, 0x00, \
                          0x00, 0x00, 0xc5, 0x51, \
                          0x00, 0x00, 0x01, 0x00, \
                          0x00, 0x00, 0xc5, 0x41, \
                          0x00, 0x00, 0x00, 0x00, \
                          0x04, 0x00, 0x00, 0x00, \
                          0x00, 0x00, 0xc5, 0x51, \
                          0x00, 0x00, 0x01, 0x00, \
                          0x00, 0x00, 0xc5, 0x41, \
                          0x00, 0x00, 0x00, 0x00, \
                          0x04, 0x00, 0x00, 0x00, \
                          0x00, 0x00, 0xc5, 0x51, \
                          0x00, 0x00, 0x01, 0x00, \
                          0x00, 0x00, 0xc5, 0x41, \
                          0x00, 0x00, 0x00, 0x00, \
                          0x04, 0x00, 0x00, 0x00, \
                          0x00, 0x00, 0xc5, 0x51, \
                          0x00, 0x00, 0x01, 0x00, \
                          0x00, 0x00, 0xc5, 0x41, \
                          0x00, 0x00, 0x00, 0x00, \
                          0x04, 0x00, 0x00, 0x00, \
                          0x00, 0x00, 0xc5, 0x51, \
                          0x00, 0x00, 0x01, 0x00, \
                          0x00, 0x00, 0xc5, 0x41, \
                          0x00, 0x00, 0x00, 0x00, \
                          0x04, 0x00, 0x00, 0x00, \
                          0x00, 0x00, 0xc5, 0x51, \
                          0x00, 0x00}

//-----------------------------------------cardon.c------------------------­­-------------------------


/* Standard wireless file, that comes with hostAP */
#include "wireless.h"


unsigned long return = 0;                    // The return value
char requestlowlevel[]= REQUESTLOWLEVEL;  // The command string
int   sd;          // The socket that the request is sent to


struct iwreq iwr;  //From wireless.h


unsigned char msg[MSIZE];               // The command
comm_t*    cmd = (comm_t*)ms;      // fill in the arguments into the
message.
                                   // Not sure if this is correct!!
bzero(ms, MSIZE);
memcpy(ms, requestlowlevel, sizeof(requestlowlevel));   //Not sure if
this is correct!!


// Fill in the message
cmd->cmd = TURNCARDON;


memset(&iwr, 0, sizeof(iwr));
strncpy(iwr.ifr_name, name, NAMELEN);
iwr.u.data.pointer = (caddr_t*)ms;                       //Not sure if
this is correct!!
iwr.u.data.length = MSIZE;


/* Create socket */
sd = socket(AF_INET, SOCK_STREAM, 0);


if(-1 == sd){
     perror("Could not open socket");
     return = ERR;



}


if(0 == ret){
     /* Do ioctl call */
     /* Note sure if the SIOCGIWPRIV is correct */
     if (ioctl(sd, SIOCGIWPRIV, &iwr)  == -1){
          perror("Bad ioctl request");
          return = ERR;
     }


}


return = (return|!cmd->stat);
return(return);


}


//-----------------------------END-----------------------------------------

Once again, as i said before, I am pretty new to programming low level
devices. Any help will be appreciated, I am looking for ideas,
examples, and type of help. I have been going at this problem for a
long while now.


Thanks,
Jimmie






More information about the HostAP mailing list