uint8_t CC110x::receiveData(uint8_t *buf) { // read data packet from RX FIFO uint8_t rxBytes = readReg(CC1101_RXBYTES, CC1101_STATUS); // how many bytes are in the buffer //Serial << rxBytes << ' '; if ((rxBytes & 0x7F) && !(rxBytes & 0x80)) { // any byte waiting to be read and no overflow? buf[0] = readReg(CC1101_RXFIFO, CC1101_CONFIG); // read data length if (buf[0] > CC1101_DATA_LEN) // if packet is too long buf[0] = 0; // discard packet else { readBurst(&buf[1], CC1101_RXFIFO, buf[0]); // read data packet readReg(CC1101_RXFIFO, CC1101_CONFIG); // read RSSI uint8_t val = readReg(CC1101_RXFIFO, CC1101_CONFIG); // read LQI and CRC_OK lqi = val & 0x7F; crc_ok = bitRead(val, 7); } } else { buf[0] = 0; // nothing to do, or overflow } cmdStrobe(CC1101_SFRX); // flush Rx FIFO cmdStrobe(CC1101_SIDLE); // enter IDLE state cmdStrobe(CC1101_SRX); // back to RX state cmdStrobe(CC1101_SWORRST); // reset real time clock // trx868.rfState = RFSTATE_RX; // declare to be in Rx state #if defined(CC_DBG) // debug message, string should be short, otherwise program stops if (buf[0] > 0) Serial << pHexL(&buf[1], buf[0]) << pTime(); #endif return buf[0]; // return the data buffer }
//************************************************************************************* void CConsoleAlarmAlertSession::GetUserTimeL(const RMessage2& aMessage) { TTime time; time.HomeTime(); time+=TTimeIntervalMinutes(iConsole->GetTimeInterval()); TPtrC8 pTime((TUint8 *)&time,sizeof(TTime)); aMessage.WriteL(KSlot0,pTime); }
BOOL CTorrentTrackerDlg::OnInitDialog() { CSkinDialog::OnInitDialog(); SetIcon( theApp.LoadIcon( IDR_MAINFRAME ), TRUE ); SkinMe( _T("CTorrentTrackerDlg") ); m_sName = m_pInfo.m_sName; m_sTracker = m_pInfo.m_sTracker; m_sComment = m_pInfo.m_sComment; m_sCreatedBy = m_pInfo.m_sCreatedBy; if ( m_pInfo.m_tCreationDate > 0 ) { CTime pTime( (time_t)m_pInfo.m_tCreationDate ); m_sCreationDate = pTime.Format( _T("%Y-%m-%d %H:%M") ); } CRect rc; m_wndFiles.GetClientRect( &rc ); rc.right -= GetSystemMetrics( SM_CXVSCROLL ); m_wndFiles.SetImageList( ShellIcons.GetObject( 16 ), LVSIL_SMALL ); m_wndFiles.InsertColumn( 0, _T("Filename"), LVCFMT_LEFT, rc.right - 80, -1 ); m_wndFiles.InsertColumn( 1, _T("Size"), LVCFMT_RIGHT, 80, 0 ); Skin.Translate( _T("CTorrentTrackerList"), m_wndFiles.GetHeaderCtrl() ); for ( int nFile = 0 ; nFile < m_pInfo.m_nFiles ; nFile++ ) { CBTInfo::CBTFile* pFile = m_pInfo.m_pFiles + nFile; LV_ITEM pItem; ZeroMemory( &pItem, sizeof(pItem) ); pItem.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_PARAM; pItem.iItem = m_wndFiles.GetItemCount(); pItem.lParam = (LPARAM)nFile; pItem.iImage = ShellIcons.Get( pFile->m_sPath, 16 ); pItem.pszText = (LPTSTR)(LPCTSTR)pFile->m_sPath; pItem.iItem = m_wndFiles.InsertItem( &pItem ); m_wndFiles.SetItemText( pItem.iItem, 1, Settings.SmartVolume( pFile->m_nSize, FALSE ) ); } m_wndStartDownloads.SetItemData( 0, dtAlways ); m_wndStartDownloads.SetItemData( 1, dtWhenRatio ); m_wndStartDownloads.SetItemData( 2, dtNever ); m_wndStartDownloads.SetCurSel( *m_pStartTorrentDownloads ); UpdateData( FALSE ); m_hThread = NULL; PostMessage( WM_COMMAND, MAKELONG( IDC_TORRENT_REFRESH, BN_CLICKED ), (LPARAM)m_wndRefresh.GetSafeHwnd() ); return TRUE; }
uint8_t CC110x::sendData(uint8_t *buf, uint8_t burst) { // send data packet via RF // Going from RX to TX does not work if there was a reception less than 0.5 // sec ago. Due to CCA? Using IDLE helps to shorten this period(?) //ccStrobe(CC1100_SIDLE); //uint8_t cnt = 0xff; //while(cnt-- && (ccStrobe( CC1100_STX ) & 0x70) != 2) //my_delay_us(10); cmdStrobe(CC1101_SIDLE); // go to idle mode cmdStrobe(CC1101_SFRX ); // flush RX buffer cmdStrobe(CC1101_SFTX ); // flush TX buffer //Serial << "tx\r\n"; if (burst) { // BURST-bit set? cmdStrobe(CC1101_STX ); // send a burst _delay_ms(360); // according to ELV, devices get activated every 300ms, so send burst for 360ms //Serial << "send burst\r\n"; } else { _delay_ms(1); // wait a short time to set TX mode } writeBurst(CC1101_TXFIFO, buf, buf[0]+1); // write in TX FIFO cmdStrobe(CC1101_SFRX); // flush the RX buffer cmdStrobe(CC1101_STX); // send a burst for(uint8_t i=0; i< 200;++i) { // after sending out all bytes the chip should go automatically in RX mode if( readReg(CC1101_MARCSTATE, CC1101_STATUS) == MARCSTATE_RX) break; //now in RX mode, good if( readReg(CC1101_MARCSTATE, CC1101_STATUS) != MARCSTATE_TX) { break; //neither in RX nor TX, probably some error } _delay_us(10); } //uint8_t cnt = 0xff; //while(cnt-- && (sendSPI(CC1101_SRX) & 0x70) != 1) //delayMicroseconds(10); #if defined(CC_DBG) // some debug message Serial << F("<- ") << pHexL(&buf[0], buf[0]+1) << pTime(); #endif //Serial << "rx\r\n"; return true; }
BOOL CTorrentGeneralPage::OnInitDialog() { if ( ! CPropertyPageAdv::OnInitDialog() ) return FALSE; ASSUME_LOCK( Transfers.m_pSection ); CDownload* pDownload = ((CDownloadSheet*)GetParent())->GetDownload(); ASSERT( pDownload && pDownload->IsTorrent() ); CBTInfo& oInfo = pDownload->m_pTorrent; m_sName = oInfo.m_sName; m_sComment = oInfo.m_sComment; m_sCreatedBy = oInfo.m_sCreatedBy; if ( oInfo.m_tCreationDate > 0 ) { CTime pTime( (time_t)oInfo.m_tCreationDate ); m_sCreationDate = pTime.Format( _T("%Y-%m-%d %H:%M") ); } // Assembler 'other' string if ( oInfo.m_bPrivate ) { m_sTorrentOther += LoadString( IDS_BT_PRIVATE ); m_sTorrentOther += _T(", "); } if ( oInfo.HasEncodingError() ) { m_sTorrentOther += LoadString( IDS_BT_ENCODING ); m_sTorrentOther += _T(", "); } // Cut off last comma if ( ! m_sTorrentOther.IsEmpty() ) m_sTorrentOther = m_sTorrentOther.Left( m_sTorrentOther.GetLength() - 2 ); m_wndStartDownloads.SetCurSel( oInfo.m_nStartDownloads ); m_sUploadTotal.Format( _T(" %s"), (LPCTSTR)Settings.SmartVolume( oInfo.m_nTotalUpload ) ); UpdateData( FALSE ); return TRUE; }
void ElPoly::FetchPore(){ FILE *FNano = fopen("NanoPos.sh","w"); double OldPos[5] = {pNanoPos(0,0),pNanoPos(0,1),pNanoPos(0,2),Nano->Rad,Nano->Height}; FILE *StalkArea = fopen("PoreArea.dat","w"); fprintf(StalkArea,"#time rad asy\n"); for(int f=NFile[0];f<NFile[1];f++){ Processing(f); if(OpenRisk(cFile[f],BF_PART)) return; double Asy = PorePos(); Nano[0].Shape = ShapeId("pore"); Nano->Height = .2; char String[120]; StringNano(String,0); fprintf(StalkArea,"%lf %lf %lf\n",pTime(),Nano->Rad,Asy); fprintf(FNano,"sed '/pore/c\\%s' %s > Ciccia.dat\n",String,cFile[f]); fprintf(FNano,"mv Ciccia.dat %s\n",cFile[f]); //command("chmod u+x %s\n","NanoPos.txt"); //SubNanoHeader(cFile[f]); } fclose(FNano); fclose(StalkArea); printf("\n"); }
/** Simple Monte Carlo to find the best position and radius of the osculating torus. */ void ElPoly::FetchStalk(){ FILE *FNano = fopen("NanoPos.sh","w"); double OldPos[5] = {pNanoPos(0,0),pNanoPos(0,1),pNanoPos(0,2),Nano->Rad,Nano->Height}; FILE *StalkArea = fopen("StalkArea.dat","w"); char FName[60]; for(int f=NFile[0];f<NFile[1];f++){ Processing(f); if(OpenRisk(cFile[f],BF_NO)) return; SetNNano(1); if(StalkPos(OldPos)) continue; char String[120]; StringNano(String,0); fprintf(StalkArea,"%lf %lf\n",pTime(),Nano->Area); fprintf(FNano,"sed '/Rigid/c\\%s' %s > Ciccia.dat\n",String,cFile[f]); fprintf(FNano,"mv Ciccia.dat %s\n",cFile[f]); sprintf(FName,"Centered%05d.dat",f); //Write(FName); //command("chmod u+x %s\n","NanoPos.txt"); //SubNanoHeader(cFile[f]); } fclose(FNano); fclose(StalkArea); printf("\n"); }
//************************************************************************************* void CConsoleAlarmAlertSession::SetDeferTimeL(const RMessage2& aMessage) { TPckg<TTime> pTime(iDeferTime); aMessage.ReadL(KSlot0, pTime); }
bool VarData::WriteXvt(char *OutFile){ VarMessage("Write"); FILE *FileToWrite = NULL; char Line2Put[512]; FileToWrite = fopen(OutFile,"w"); SigErr(FileToWrite==NULL,"The output file %s could not be opened\n",OutFile); fprintf(FileToWrite,"# L=%lf %lf %lf t=%lf blocks=%d\n",Gen->Edge[0],Gen->Edge[1],Gen->Edge[2],pTime(),Gen->NBlock); HeaderInteraction(FileToWrite); HeaderNano(FileToWrite); for(int b=0,cOff=0,pCurr=0;b<Gen->NBlock;b++,cOff+=Block[b].NChain){ if(Block[b].NChain == 0) continue; fprintf(FileToWrite,"# n=%d N=%d name=%s\n",Block[b].NChain,Block[b].NPCh,Block[b].Name); for(int c=cOff;c<Block[b].NChain+cOff;c++){ for(int p=0;p<Block[b].NPCh;p++,pCurr++){ // if(p > 0){ // for(int d=0;d<3;d++){ // if(Pm[pCurr].Pos[d] - Pm[pCurr-1].Pos[d] > .5*pEdge(d)) // Pm[pCurr].Pos[d] -= pEdge(d); // else if(Pm[pCurr].Pos[d] - Pm[pCurr-1].Pos[d] < -.5*pEdge(d)) // Pm[pCurr].Pos[d] += pEdge(d); // } // } fprintf(FileToWrite,"%lf %lf %lf ", pPos(pCurr,0),pPos(pCurr,1),pPos(pCurr,2)); fprintf(FileToWrite,"%lf %lf %lf ", Pm[pCurr].Vel[0],Pm[pCurr].Vel[1],Pm[pCurr].Vel[2]); fprintf(FileToWrite," %d ", Pm[pCurr].Typ); fprintf(FileToWrite,"\n"); } } } fclose(FileToWrite); return 0; }
void CHostCacheWnd::Update(BOOL bForce) { if ( !bForce ) if ( !m_bAllowUpdates ) return; CSingleLock pLock( &Network.m_pSection ); if ( ! pLock.Lock( 50 ) ) return; m_wndList.ModifyStyle( WS_VISIBLE, 0 ); CLiveList pLiveList( 8 ); PROTOCOLID nEffective = m_nMode ? m_nMode : PROTOCOL_G2; CHostCacheList* pCache = HostCache.ForProtocol( nEffective ); m_nCookie = pCache->m_nCookie; int nProtocolRev = m_gdiImageList.GetImageCount() - 1; for ( CHostCacheHost* pHost = pCache->GetNewest() ; pHost ; pHost = pHost->m_pPrevTime ) { // cancel update if mouse moves ouside window or user right-clicks // do not break if different cache window button pressed if ( !m_bAllowUpdates && !bForce ) break; if ( m_nMode == PROTOCOL_NULL ) { if ( HubHorizonPool.Find( &pHost->m_pAddress ) == NULL ) continue; } CLiveItem* pItem = pLiveList.Add( pHost ); pItem->m_nImage = theApp.m_bRTL ? nProtocolRev - pHost->m_nProtocol : pHost->m_nProtocol; pItem->m_nMaskOverlay = pHost->m_bPriority; pItem->Set( 0, CString( inet_ntoa( pHost->m_pAddress ) ) ); pItem->Format( 1, _T("%hu"), pHost->m_nPort ); #ifdef _DEBUG pItem->Format( 2, _T("K:%u A:%u Q:%u"), pHost->m_nKeyValue, pHost->m_tAck, pHost->m_tQuery ); #else if ( pHost->m_pVendor ) pItem->Set( 2, pHost->m_pVendor->m_sName ); else if ( pHost->m_nProtocol == PROTOCOL_G2 ) pItem->Set( 2, _T("(Gnutella2)") ); else if ( pHost->m_nProtocol == PROTOCOL_ED2K ) pItem->Set( 2, _T("(eDonkey Server)") ); #endif CTime pTime( (time_t)pHost->m_tSeen ); pItem->Set( 3, pTime.Format( _T("%Y-%m-%d %H:%M:%S") ) ); pItem->Set( 4, pHost->m_sName ); pItem->Set( 5, pHost->m_sDescription ); if ( pHost->m_nUserCount ) pItem->Format( 6, _T("%u"), pHost->m_nUserCount ); if ( pHost->m_nUserLimit ) pItem->Format( 7, _T("%u"), pHost->m_nUserLimit ); } if ( !m_bAllowUpdates && !bForce ) return; pLiveList.Apply( &m_wndList, TRUE ); m_wndList.ShowWindow( SW_SHOW ); tLastUpdate = GetTickCount(); // Update timer }
/** Simple Monte Carlo to find the best position and radius of the osculating torus. The area and position of the torus are hence redifined counting how many hydrophilic beads are inside the torus. */ void ElPoly::StalkArea(){ FILE *FNano = fopen("NanoPosA.sh","w"); FILE *StalkArea = fopen("StalkArea.dat","w"); FILE *AreaS = fopen("AreaS.dat","w"); double OldPos[5] = {pNanoPos(0,0),pNanoPos(0,1),pNanoPos(0,2),Nano->Rad,Nano->Height}; int NBin = 36; double *Count = (double *)calloc(NBin*NBin,sizeof(double)); double RadTorus = 1.;//Nano->Rad; //fprintf(AreaS,"#l(%lf %lf %lf) \n",2.*Nano->Height,2.*Nano->Height,10.); fprintf(AreaS,"#l(%lf %lf %lf) \n",pEdge(0),pEdge(1),pEdge(2)); HeaderNano(AreaS); char FName[60]; for(int f=NFile[0];f<NFile[1];f++){ Processing(f); if(OpenRisk(cFile[f],BF_NO)) return; SetNNano(1); if(StalkPos(OldPos)) continue; //Nano->Pos[CNorm] = pCm(CNorm); //Nano->Pos[CNorm] -= floor(Nano->Pos[CNorm]*pInvEdge(CNorm))*pEdge(CNorm); double Cm[3] = {0.,0.,0.}; double CountCm = 0; int nPart = 0; double Pos[3]; //counts the particles inside the torus for(int p=0;p<pNPart();p++){ for(int d=0;d<3;d++){ Pos[d] = pPos(p,d) - Nano->Pos[d]; Pos[d] -= floor(pPos(p,d)*pInvEdge(d))*pEdge(d); } double Rad = hypot(Pos[CLat1],Pos[CLat2]); if(Rad > Nano->Height) continue; if(fabs(Pos[CNorm]) > RadTorus) continue; // fprintf(AreaS,"{t[%d 0 %d] x(%lf %lf %lf)",nPart++,pType(p),pPos(p,0),pPos(p,1),pPos(p,2)); // if(Ln[p].NLink > 0) fprintf(AreaS,"l[%d]",p-Ln[p].Link[0]+nPart+1); // fprintf(AreaS,"}\n"); if(pType(p) == 1) continue; for(int d=0;d<3;d++){ Cm[d] += pPos(p,d); } CountCm += 1.; int vx = (int)(Pos[CLat1]/(2.*Nano->Height)*NBin); vx += NBin/2; if(vx < 0 || vx >= NBin) continue; int vy = (int)(Pos[CLat2]/(2.*Nano->Height)*NBin); vy += NBin/2; if(vy < 0 || vy >= NBin) continue; Count[vx*NBin+vy] += 1.; } double Area = 0.; double Norm = 0.; for(int vx=0;vx<NBin;vx++){ for(int vy=0;vy<NBin;vy++){ if(Count[vx*NBin+vy] < 1.) continue; // double x = vx*Nano->Height*2./(double)NBin; // double y = vy*Nano->Height*2./(double)NBin; // fprintf(AreaS,"{t[%d 0 2] x(%lf %lf %lf)}\n",nPart++,x+pNanoPos(0,0)-Nano->Height,y+pNanoPos(0,1)-Nano->Height,pNanoPos(0,2)); Area += 1.; } } if(CountCm <= 0.){ printf("No particles in the torus %s\n",cFile[f]); return; } Nano->Area = SQR(2.*Nano->Height)*Area/(double)(SQR(NBin)); for(int d=0;d<3;d++){ Cm[d] /= CountCm; } Cm[CNorm] = pCm(CNorm); //fprintf(AreaS,"%lf %lf %lf\n",Cm[0]-Nano->Pos[0],Cm[1]-Nano->Pos[1],Cm[2]-Nano->Pos[2]); for(int d=0;d<3;d++){ Nano->Pos[d] = Cm[d] - floor(Cm[d]*pInvEdge(d))*pEdge(d); fprintf(StalkArea,"%lf %lf\n",pTime(),Nano->Area); } SetNanoBkf(0); Nano->Height = Nano->Rad + sqrt(Nano->Area/DUE_PI); char String[120]; StringNano(String,0); fprintf(StalkArea,"%lf %lf\n",pTime(),Nano->Area); fprintf(FNano,"sed '/Rigid/c\\%s' %s > Ciccia.dat\n",String,cFile[f]); fprintf(FNano,"mv Ciccia.dat %s\n",cFile[f]); sprintf(FName,"Centered%05d.dat",f); //Write(FName); //HeaderNano(AreaS); } fclose(AreaS); fclose(StalkArea); fclose(FNano); free(Count); printf("\n"); }
void TCmdModifyAudioCodec::ExecuteL() { // ---------- Setup -------------------------------------------------------- // Get codec CMceAudioCodec* codec = reinterpret_cast<CMceAudioCodec*>(GetObjectForIdL(KCodecId, ETrue)); /*CMceAmrCodec* codec = reinterpret_cast<CMceAmrCodec*>(GetObjectForIdL(KCodecId, ETrue));*/ // ---------- Execution ---------------------------------------------------- // VAD TBool enableVad = EFalse; TRAPD( err, enableVad = ExtractBooleanL( KParamVAD, ETrue ) ); if ( err != KTcErrMandatoryParameterNotFound ) { codec->EnableVAD( enableVad ); } // Bitrate TInt bitrate( 0 ); TRAP( err, bitrate = ExtractIntegerL( KParamBitrates, 0, ETrue )); if ( err != KTcErrMandatoryParameterNotFound ) { codec->SetBitrate( bitrate ); } // SamplingFrequency TInt samplingFrequency( 0 ); TRAP( err, samplingFrequency = ExtractIntegerL( KParamSamplingFreq, 0, ETrue )); if ( err != KTcErrMandatoryParameterNotFound ) { codec->SetSamplingFreq( samplingFrequency ); } // PayloadType TInt payloadType( 0 ); TRAP( err, payloadType = ExtractIntegerL( KParamPayloadType, 0, ETrue )); if ( err != KTcErrMandatoryParameterNotFound ) { codec->SetPayloadType( payloadType ); } // CodecMode TInt codecMode( 0 ); TRAP( err, codecMode = ExtractIntegerL( KParamCodecMode, 0, ETrue )); if ( err != KTcErrMandatoryParameterNotFound ) { codec->SetCodecMode( codecMode ); } // PTime TInt pTime( 0 ); TRAP( err, pTime = ExtractIntegerL( KParamPTime, 0, ETrue )); if ( err != KTcErrMandatoryParameterNotFound ) { codec->SetPTime( pTime ); } // MaxPTime TInt maxPTime( 0 ); TRAP( err, maxPTime = ExtractIntegerL( KParamMaxPTime, 0, ETrue )); if ( err != KTcErrMandatoryParameterNotFound ) { codec->SetMaxPTime( maxPTime ); } //SetAllowedBiTRates TInt allowedBitRate( 0 ); TRAP(err, allowedBitRate = ExtractIntegerL(KParamAllowedBitRate, 0, ETrue)); if(err != KTcErrMandatoryParameterNotFound) { codec->SetAllowedBitrates(allowedBitRate); } // ---------- Response creation -------------------------------------------- AddIdResponseL( KCodecId, *codec ); AddTextResponseL( KResponseCodecName, codec->SdpName() ); AddIntegerResponseL( KResponseBitrates, codec->Bitrate() ); AddIntegerResponseL( KResponseSamplingFreq, codec->SamplingFreq() ); AddIntegerResponseL( KResponseCodecMode, codec->CodecMode() ); AddIntegerResponseL( KResponseFourCC, codec->FourCC() ); AddIntegerResponseL( KResponsePayloadType, codec->PayloadType() ); AddIntegerResponseL( KResponsePTime, codec->PTime() ); AddIntegerResponseL( KResponseMaxPTime, codec->MaxPTime() ); AddIntegerResponseL (KResponseAllowedBitRate, codec->AllowedBitrates()); AddBooleanResponseL( KResponseVAD, codec->VAD() ); }