📄 rxhostcomm.c
字号:
// not all data fits in a data frame, add one to make room for the rest of the data
uiNoOfFrames += 1;
}
}
}
else
{
uiNoOfFrames = uiFileSize / DATABUFFSIZE;
if (uiNoOfFrames*DATABUFFSIZE < uiFileSize)
{
uiNoOfFrames += 1;
}
}
uiNoOfFrames += 1; // for the start frame
*(HostCommState.puiNoOfBlocks) = uiNoOfFrames;
HostCommState.cTransReady = 1;
if (HostCommState.cTransReady)
{
HostCommState.cTransReady = 0;
//iStatus = RTDX_write( &ochancrtl, HostCommState.puiNoOfBlocks, sizeof((HostCommState.puiNoOfBlocks)) );
iStatus = RTDX_write( &ochancrtl, &uiNoOfFrames, sizeof((HostCommState.puiNoOfBlocks)) );
if ( iStatus == 0 ) {
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"ERROR: RTDX_write failed!");
#endif
exit( EXIT_RTDX_WRITE_FAILED );
}
while ( RTDX_writing != NULL ) {
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
TSK_sleep(1);
}
CommState = eRXHST_GETSTATUS;
//startEdma();
}
break;
case eRXHST_GETSTATUS:
SEM_pend(&hstsem, SYS_FOREVER);
if (HostCommState.cNewFrameReady)
{
HostCommState.cNewFrameReady = 0;
// Frame number
iStatus = RTDX_write( &ochancrtl, HostCommState.puiFrameNbr, sizeof((HostCommState.puiFrameNbr)) );
if ( iStatus == 0 ) {
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"ERROR: RTDX_write failed!");
#endif
exit( EXIT_RTDX_WRITE_FAILED );
}
// Convert the channel estimates from complex [4][2] to real power [8]
for (i=0; i<4; i++)
{
for (j=0;j<2;j++)
{
pH_a[2*i+j] = pH_pre_r[i][j] * pH_pre_r[i][j] +pH_pre_i[i][j] * pH_pre_i[i][j];
}
}
while ( RTDX_writing != NULL ) {
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
TSK_sleep(1);
}
// Sending channel amplitudes
iStatus = RTDX_write( &ochancrtl, pH_a, sizeof(pH_a) );
if ( iStatus == 0 ) {
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"ERROR: RTDX_write failed!");
#endif
exit( EXIT_RTDX_WRITE_FAILED );
}
while ( RTDX_writing != NULL ) {
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
TSK_sleep(1);
}
// Antenna selection
iStatus = RTDX_write( &ochancrtl, &uiSwitchPos, sizeof(uiSwitchPos) );
while ( RTDX_writing != NULL ) {
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
TSK_sleep(1);
}
// Least significant bit: Antenna 1 or 2, Second bit: Antenna 3 or 4
uiSwitchPos = *(HostCommState.puiPosSwitch1) + 2 * *(HostCommState.puiPosSwitch2);
}
if (*(HostCommState.pRxState) == eRX_FINDSTART)
CommState = eRXHST_TRANSMITTFILE;
break;
case eRXHST_TRANSMITTFILE:
// Debug
*(HostCommState.puiFileSizeHat) = uiFileSize;
// Are the size files the same (received file from transmitter and file selected in the GUI)
if (*(HostCommState.puiFileSizeHat) != uiFileSize)
{
#ifdef _DEBUGLOG
LOG_printf(&trace,"Sending the data...!");
#endif
exit( EXIT_FILESIZES_DIFFER );
}
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"Sending the data...!");
#endif
for (p=1;p<=uiNbrDataBursts;p++)
{
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"RTDX Writing!");
#endif
memcpy(arraydata, pFileBuffer, DATABURSTLEN*sizeof(int));
pFileBuffer += DATABURSTLEN*sizeof(int);
iStatus = RTDX_write( &ochandata, arraydata, sizeof(arraydata) );
while ( RTDX_writing != NULL ) {
#if RTDX_POLLING_IMPLEMENTATION
RTDX_Poll();
#endif
TSK_sleep(1);
}
if ( iStatus == 0 ) {
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"ERROR: RTDX_write failed!");
#endif
exit( EXIT_RTDX_WRITE_FAILED );
}
iStatus = RTDX_read( &ichancrtl, &uiCrtl, sizeof(uiCrtl) );
if ( iStatus == 0 ) {
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"ERROR: RTDX_read failed!");
#endif
exit( EXIT_RTDX_WRITE_FAILED );
}
if (uiCrtl != p)
{
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"ERROR: Received and sent value do not match!");
#endif
exit( EXIT_RTDX_READ_FAILED );
}
}
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"Transmission Complete!");
#endif
CommState = eRXHST_IDLE;
break;
default:
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"Comm: Defaut state");
#endif
break;
}
TSK_yield();
}
}
/****************************************************************************
Function : tskHostCommInitialize
****************************************************************************
Description : Enable the RTDX channels
Inputs : None
Outputs : None
By : 2005-05-14 Maxime Maury
****************************************************************************/
void tskHostCommInitialize()
{
/* enable the output channel */
RTDX_enableOutput( &ochancrtl );
/* enable the output channel */
RTDX_enableOutput( &ochandata );
/* enable the input channel */
RTDX_enableInput( &ichancrtl );
/* enable the intput channel */
RTDX_enableInput( &ichandata );
CommState = eRXHST_IDLE;
#ifdef _RTDXDEBUGLOG
LOG_printf(&trace,"Channels enabled!");
#endif
}
/*=== End of global functions definition ===================================*/
/*--- AUTOMATICALLY GENERATED VERSION HISTORY --------------------------------
$Log: /MIMO/Receiver/rxhostcomm.c $
*
* 10 05-06-01 0:47 Adrian
* small modifications and some debug code
*
* 9 27/05/05 12:59 Maxime
* Debugged the transfer of channel estimates
*
* 8 05-05-26 18:47 Adrian
* added the routine from the transmitter to compute the number of frames
*
* 7 23/05/05 11:27 Maxime
* The switch state sent to the hostcomm is one step-ahead. The one sent
* to the GUI is now the one used for the current frame
*
* 5 22/05/05 20:55 Maxime
* Test file sizes before transmitting to the host
*
* 4 21/05/05 19:23 Maxime
*
* 3 19/05/05 12:26 Maxime
* Communicating part with the host written
*
* 1 05-05-11 14:50 Adrian
* created and added to VSS
===== END OF AUTOMATICALLY GENERATED VERSION HISTORY =======================*/
/**** End of file ***********************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -