Author: gkruse Date: 2007-02-17 06:00:29 +0100 (Sat, 17 Feb 2007) New Revision: 223 Modified: branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.h branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm branches/usb-drivers/Sources/Driver/USBJack/USBJack.h branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm Log: No comment ;) I like the word introspection though :D Modified: branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.h 2007-02-08 07:45:23 UTC (rev 222) +++ branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.h 2007-02-17 05:00:29 UTC (rev 223) @@ -24,6 +24,7 @@ bool getChannel(UInt16* channel); bool getAllowedChannels(UInt16* channel); bool setChannel(UInt16 channel); + int WriteTxDescriptor(WLFrame * theFrame); private: Modified: branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm 2007-02-08 07:45:23 UTC (rev 222) +++ branches/usb-drivers/Sources/Driver/USBJack/IntersilJack.mm 2007-02-17 05:00:29 UTC (rev 223) @@ -189,6 +189,13 @@ return kIOReturnSuccess; } +int IntersilJack::WriteTxDescriptor(WLFrame * theFrame){ + theFrame->rate = 0x6e; //11 MBit/s + theFrame->tx_rate = 0x6e; //11 MBit/s + //where does this come from? sizeof(WLFrame)? + return 0x3C; +} + IntersilJack::IntersilJack() { } Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h 2007-02-08 07:45:23 UTC (rev 222) +++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.h 2007-02-17 05:00:29 UTC (rev 223) @@ -85,6 +85,8 @@ bool stopCapture(); bool _massagePacket(int len); + int WriteTxDescriptor(WLFrame * theFrame); + private: int temp; Modified: branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2007-02-08 07:45:23 UTC (rev 222) +++ branches/usb-drivers/Sources/Driver/USBJack/RalinkJack.mm 2007-02-17 05:00:29 UTC (rev 223) @@ -1041,6 +1041,119 @@ return true; } +int RalinkJack::WriteTxDescriptor(WLFrame * theFrame){ + //here we will constrict a TXD_STRUC from the contents of theFrame + //and some defaults taken from the linux driver + //then, WLFrame will be overwritten with the TXD_STRUC and + //sizeof(TXD_STRUC) will be returned + TXD_STRUC * pTxD; + UInt8 tempFrame[sizeof(TXD_STRUC)]; + pTxD = (TXD_STRUC *)&tempFrame; + //todo fixme!! + + //stuff it + pTxD->RetryLimit = 0; + pTxD->MoreFrag = false; + pTxD->ACK = false; + pTxD->Timestamp = false; + pTxD->newseq = new_seq; + //pTxD->IFS = Ifs; + pTxD->DataByteCnt = theFrame->length; + pTxD->Cipher = false; + pTxD->KeyID = 0; + pTxD->CWmin = 2^5-1;// = 31 + pTxD->CWmax = 2^10 -1;// = 1023 + pTxD->Aifs = 2; // TC0: SIFS + 2*Slot + Random(CWmin,CWmax)*Slot + //maybe? + pTxD->Ofdm = 1; + + +/* + Fragment, //false + IN UCHAR RetryLimit, 0 + IN BOOLEAN Ack, //false + IN BOOLEAN InsTimestamp, //false + IN BOOLEAN new_seq, //true + IN UCHAR Ifs, //IFS_BACKOFF + IN UINT Length, //length of packet + IN BOOLEAN Cipher, //false + IN UCHAR KeyID, //0 + IN UCHAR CWMin, // CW_MIN_IN_BITS + IN UCHAR CWMax, //CW_MAX_IN_BITS + IN UINT PLCPLength, //len + 4 + IN UINT Rate, //tx rate + IN UCHAR Service, //4 + IN USHORT TxPreamble) //preamble + UINT Residual; + + pTxD->RetryLimit = RetryLimit; + pTxD->MoreFrag = Fragment; + pTxD->ACK = Ack; + pTxD->Timestamp = InsTimestamp; + pTxD->newseq = new_seq; + pTxD->IFS = Ifs; + pTxD->DataByteCnt = Length; + pTxD->Cipher = Cipher; + pTxD->KeyID = KeyID; + pTxD->CWmin = CWMin; // 2^5-1 = 31 + pTxD->CWmax = CWMax; // 2^10 -1 = 1023 + pTxD->Aifs = 2; // TC0: SIFS + 2*Slot + Random(CWmin,CWmax)*Slot + + if (Rate < RATE_FIRST_OFDM_RATE) + pTxD->Ofdm = 0; + else + pTxD->Ofdm = 1; + + // fill up PLCP SIGNAL field + pTxD->PlcpSignal = PlcpSignal[Rate]; + if (((Rate == RATE_2) || (Rate == RATE_5_5) || (Rate == RATE_11)) && (TxPreamble == Rt802_11PreambleShort)) // no short preamble for RATE_1 + { + pTxD->PlcpSignal |= 0x0008; + } + + // fill up PLCP SERVICE field, not used for OFDM rates + pTxD->PlcpService = Service; + + // file up PLCP LENGTH_LOW and LENGTH_HIGH fields + if (Rate < RATE_FIRST_OFDM_RATE) // 11b - RATE_1, RATE_2, RATE_5_5, RATE_11 + { + if ((Rate == RATE_1) || ( Rate == RATE_2)) + { + PLCPLength = PLCPLength * 8 / (Rate + 1); + } + else + { + Residual = ((PLCPLength * 16) % (11 * (1 + Rate - RATE_5_5))); + PLCPLength = PLCPLength * 16 / (11 * (1 + Rate - RATE_5_5)); + if (Residual != 0) + { + PLCPLength++; + } + if (Rate == RATE_11) + { + if ((Residual <= (3 * (1 + Rate - RATE_5_5))) && (Residual != 0)) + { + pTxD->PlcpService |= 0x80; // 11b's PLCP Length extension bit + } + } + } + + pTxD->PlcpLengthHigh = PLCPLength / 256; + pTxD->PlcpLengthLow = PLCPLength % 256; + } + else // OFDM - RATE_6, RATE_9, RATE_12, RATE_18, RATE_24, RATE_36, RATE_48, RATE_54 + { + pTxD->PlcpLengthHigh = PLCPLength / 64; // high 6-bit of total byte count + pTxD->PlcpLengthLow = PLCPLength % 64; // low 6-bit of total byte count + } +} +*/ + //now copy the txd_struc over the old wlframe + memcpy(theFrame, tempFrame, sizeof(TXD_STRUC)); + + return sizeof(TXD_STRUC); +} + bool RalinkJack::_massagePacket(int len){ unsigned char* pData; UInt8 frame[sizeof(_recieveBuffer)]; Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.h =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2007-02-08 07:45:23 UTC (rev 222) +++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.h 2007-02-17 05:00:29 UTC (rev 223) @@ -98,6 +98,7 @@ static void _handleDeviceRemoval(void *refCon, io_iterator_t iterator); static void _interruptRecieved(void *refCon, IOReturn result, int len); virtual bool _massagePacket(int len); + virtual int WriteTxDescriptor(WLFrame * theFrame); static void _runCFRunLoop(USBJack* me); // static IOUSBDeviceInterface **_foundDevices[10]; Modified: branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm =================================================================== --- branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm 2007-02-08 07:45:23 UTC (rev 222) +++ branches/usb-drivers/Sources/Driver/USBJack/USBJack.mm 2007-02-17 05:00:29 UTC (rev 223) @@ -177,8 +177,11 @@ WLFrame *frameDescriptor; UInt8 aData[2364]; IOByteCount pktsize; + int descriptorLength; + //copy the wl frame to the tx buff memcpy(aData, data, sizeof(WLFrame)); + //modify the frame descriptor in the txbuff frameDescriptor = (WLFrame*)aData; switch(frameDescriptor->frameControl & 0x0c) { case 0x08: @@ -194,15 +197,19 @@ default: return kIOReturnBadArgument; } - + frameDescriptor->txControl=NSSwapHostShortToLittle(0x08 | _TX_RETRYSTRAT_SET(3)| _TX_CFPOLL_SET(1) | _TX_TXEX_SET(0) | _TX_TXOK_SET(0) | _TX_MACPORT_SET(0)); - frameDescriptor->rate = 0x6e; //11 MBit/s - frameDescriptor->tx_rate = 0x6e; //11 MBit/s - - memcpy(aData + 0x3C, data + sizeof(WLFrame), pktsize); - - if (_sendFrame(aData, pktsize + 0x3C) != kIOReturnSuccess) + //write the device dependant descriptor and return the length to copy + //note frame descriptor = txbuff + descriptorLength = WriteTxDescriptor(frameDescriptor); + //copy the packet data to the end of the descriptor + //this is 0x3c on prismII + //todo fixme!! we need to make sure the buffer is long enough! + memcpy(aData + descriptorLength, data + sizeof(WLFrame), pktsize); + + //send the frame + if (_sendFrame(aData, pktsize + descriptorLength) != kIOReturnSuccess) return NO; return YES; @@ -466,6 +473,7 @@ _lockDevice(); memcpy(&_outputBuffer, data, size); + //not sure about this _outputBuffer.type = NSSwapHostShortToLittle(_USB_TXFRM); numBytes = align64(size); @@ -636,6 +644,7 @@ IOUSBConfigurationDescriptorPtr confDesc; kr = (*dev)->GetNumberOfConfigurations(dev, &numConf); + NSLog(@"Number of configs found: %d\n", numConf); if (!numConf) return kIOReturnError; @@ -1060,4 +1069,11 @@ pthread_mutex_destroy(&_recv_mutex); pthread_cond_destroy(&_recv_cond); -} \ No newline at end of file +} + +int USBJack::WriteTxDescriptor(WLFrame * theFrame){ + theFrame->rate = 0x6e; //11 MBit/s + theFrame->tx_rate = 0x6e; //11 MBit/s + //where does this come from? sizeof(WLFrame)? + return 0x3C; +} Modified: branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm =================================================================== --- branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm 2007-02-08 07:45:23 UTC (rev 222) +++ branches/usb-drivers/Sources/WaveDrivers/WaveDriverUSBIntersil.mm 2007-02-17 05:00:29 UTC (rev 223) @@ -41,6 +41,7 @@ _driver = new USBJack; //this will only occur once! _driver->startMatching(); + NSLog(@"Matching finished\n"); while(!_driver->getDeviceType() && timeoutCount++ < 10) //wait until the device is found usleep(100); @@ -65,6 +66,7 @@ break; default: NSLog(@"No supported USB Device found!"); + delete(_driver); _errors++; return Nil; }