cbsref/csyrefplugins/csy27010/src/CommFrameWriterAo.cpp
author hgs
Tue, 22 Jun 2010 11:02:32 +0100
changeset 44 8b72faa1200f
permissions -rw-r--r--
201024_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     1
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     2
// * Copyright 2004 Neusoft America Inc.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     3
// * All rights reserved.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     4
// * This component and the accompanying materials are made available
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     5
// * under the terms of the Eclipse Public License v1.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     6
// * which accompanies this distribution, and is available
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     7
// * at the URL "http://www.eclipse.org/legal/epl-v10.html".
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     8
// *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     9
// * Contributors:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    10
// * Keith Collins (Neusoft America Inc.)  original software development and additional code and modifications.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    11
// * Thomas Gahagen (Neusoft America Inc.)  additional code and modifications.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    12
// * Zhen Yuan (Neusoft America Inc.)  additional code and modifications.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    13
// *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    14
// * Description:  This file contains the implemenation for the CCommFrameWriterAo class.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    15
// *               This class is used to handle the write operations to the serial port
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    16
// *               logical device driver.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    17
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    18
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    19
// CommFrameWriterAo.cpp
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    20
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    21
/** @file CommFrameWriterAo.cpp
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    22
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    23
 * This file contains the implemenation for the CCommFrameWriterAo class.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    24
 * This class is used to handle the write operations to the serial port
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    25
 * logical device driver.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    26
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    27
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    28
#include "CommFrameWriterAo.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    29
#include "CsyMsgBufBPFrame.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    30
#include "Mux0710Protocol.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    31
#include "CsyDebugLogger.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    32
#include "PortC32InterfaceBase.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    33
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    34
CCommFrameWriterAo* CCommFrameWriterAo::NewL(CPortFactory* aParent, CMux0710Protocol* aMux0710Protocol)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    35
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    36
 * This method uses two phase construction and the cleanup stack to
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    37
 * create an instance of class CCommFrameWriterAo. 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    38
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    39
 * @param aParent - Pointer to the parent object
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    40
 * @param aMux0710Protocol - Pointer to mux protocol object
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    41
 * @return Pointer to new instance of CCommFrameWriterAo
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    42
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    43
    {
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    44
	_LOG_L4C1("CCommFrameWriterAo::NewL");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    45
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    46
    CCommFrameWriterAo* obj = new (ELeave) CCommFrameWriterAo(aParent, aMux0710Protocol);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    47
    CleanupStack::PushL(obj);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    48
    obj->ConstructL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    49
    CleanupStack::Pop();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    50
    return (obj);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    51
    }
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    52
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    53
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    54
CCommFrameWriterAo::~CCommFrameWriterAo()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    55
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    56
 * Destructor.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    57
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    58
    {
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    59
	_LOG_L4C1("CCommFrameWriterAo::~CCommFrameWriterAo");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    60
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    61
    Cancel();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    62
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    63
 	// Remove the frames in Write Buf List
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    64
	CCsyMsgBufBpFrame* frame;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    65
	iWriteFrameBufIter.SetToFirst();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    66
	while ((frame = iWriteFrameBufIter++) != NULL)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    67
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    68
		iWriteFrameBufList.Remove(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    69
		delete frame;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    70
	 	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    71
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    72
 	// Remove the frames in waiting list
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    73
	iWaitingForFcOffIter.SetToFirst();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    74
	while ((frame = iWaitingForFcOffIter++) != NULL)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    75
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    76
		iWaitingForFcOffList.Remove(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    77
		delete frame;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    78
	 	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    79
   }
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    80
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    81
CCommFrameWriterAo::CCommFrameWriterAo(CPortFactory* aParent, CMux0710Protocol* aMux0710Protocol)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    82
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    83
 * Constructor.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    84
 * @param aParent - Pointer to the parent object
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    85
 * @param aMux0710Protocol - Pointer to mux protocol object
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    86
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    87
:	CCommReadWriteBaseAo(aParent, aMux0710Protocol, KFrameWriterAoPriority),
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    88
	iWriteFrameBufList(_FOFF(CCsyMsgBufBpFrame, iMsgLink)),
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    89
	iWriteFrameBufIter(iWriteFrameBufList),
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    90
	iWaitingForFcOffList(_FOFF(CCsyMsgBufBpFrame, iMsgLink)),
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    91
	iWaitingForFcOffIter(iWaitingForFcOffList)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    92
	{}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    93
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    94
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    95
void CCommFrameWriterAo::ConstructL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    96
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    97
 * Safe constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    98
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    99
    {
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   100
	_LOG_L4C1("CCommFrameWriterAo::ConstructL");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   101
	SetBuffersL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   102
    }
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   103
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   104
void CCommFrameWriterAo::RunL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   105
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   106
 * This method is called when a write to the LDD completes.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   107
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   108
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   109
	_LOG_L4C1(" ");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   110
	_LOG_L4C2(">>CCommFrameWriterAo::RunL [iStatus=%d] - written to LDD",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   111
		iStatus.Int());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   112
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   113
	if (iStatus.Int())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   114
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   115
		_LOG_L1C2("** Error writing to LDD ** [iStatus=%d]",iStatus.Int());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   116
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   117
		if (!iCompleteWhenSent)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   118
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   119
			// The frame being sent was not the last or only one for this dlc, other
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   120
			// frames exist
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   121
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   122
			// go through list and remove other frames to send for this dlc
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   123
			RemoveAnyDlcFramesOnWriteList(iDlcNum, EFalse);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   124
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   125
			iCompleteWhenSent = ETrue;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   126
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   127
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   128
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   129
	if (iCompleteWhenSent)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   130
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   131
		iCompleteWhenSent = EFalse;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   132
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   133
		_LOG_L3C2("Complete write [iDlcNum=%d]",iDlcNum);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   134
		CompleteWrite(iDlcNum,iStatus.Int());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   135
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   136
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   137
	// check for another message that needs to be sent to the baseband
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   138
	CCsyMsgBufBpFrame* bpFrame = GetFrameToWrite();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   139
	if (bpFrame)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   140
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   141
		TInt ret = KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   142
		do
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   143
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   144
			ret = WriteFrame(bpFrame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   145
			if (ret)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   146
				{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   147
				_LOG_L1C2("** Write frame failed [ret=%d] **",ret);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   148
				if (!iCompleteWhenSent)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   149
					{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   150
					// go through list and remove other frames to send for this dlc
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   151
					RemoveAnyDlcFramesOnWriteList(iDlcNum, EFalse);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   152
					}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   153
				}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   154
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   155
			// Loop around if there is an error and try and send the next frame
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   156
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   157
			while (ret);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   158
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   159
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   160
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   161
		_LOG_L3C1("Finished all writes - nothing more to send to LDD");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   162
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   163
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   164
	_LOG_L4C1("<<CCommFrameWriterAo::RunL");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   165
	_LOG_L3C1(" "); // please leave this separator in
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   166
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   167
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   168
void CCommFrameWriterAo::DoCancel()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   169
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   170
 * Cancel a pending write
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   171
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   172
    {
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   173
	_LOG_L4C1("CCommFrameWriterAo::DoCancel - cancelling LDD write");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   174
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   175
	iCommPort->WriteCancel();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   176
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   177
 	// Remove the frames in Write Buf List
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   178
	CCsyMsgBufBpFrame* frame;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   179
	iWriteFrameBufIter.SetToFirst();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   180
	while ((frame = iWriteFrameBufIter++) != NULL)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   181
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   182
		iWriteFrameBufList.Remove(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   183
		iMux0710Protocol->AddFrameFreeQ(frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   184
	 	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   185
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   186
 	// Remove the frames in waiting list
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   187
	iWaitingForFcOffIter.SetToFirst();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   188
	while ((frame = iWaitingForFcOffIter++) != NULL)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   189
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   190
		iWaitingForFcOffList.Remove(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   191
		iMux0710Protocol->AddFrameFreeQ(frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   192
	 	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   193
    }
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   194
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   195
TInt CCommFrameWriterAo::Write(CCsyMsgBufBpFrame* aBpFrame,
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   196
							   TBool aHighPriority)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   197
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   198
 * This method is called to transmit a frame to the baseband.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   199
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   200
 * @param aBpFrame - Pointer to frame
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   201
 * @param aHighPriority - Flag to indicate a high priority frame
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   202
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   203
    {
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   204
	_LOG_L4C3(">>CCommFrameWriterAo::Write [aBpFrame=0x%x, aHighPriority=%d]",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   205
		aBpFrame,aHighPriority);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   206
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   207
	TInt ret = KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   208
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   209
	// 1st check if we are already transmitting a frame
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   210
	if (!IsActive())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   211
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   212
		_LOG_L4C1("Not currently writing a frame");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   213
		ret = WriteFrame(aBpFrame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   214
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   215
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   216
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   217
		// add frame to the list of frames that need to be sent to the BP
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   218
		_LOG_L2C1("Already writing a frame - add to queue");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   219
		AddToWaitingToSendList(aBpFrame, aHighPriority);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   220
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   221
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   222
	_LOG_L4C2("<<CCommFrameWriterAo::Write [ret=%d]",ret);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   223
	return ret;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   224
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   225
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   226
TInt CCommFrameWriterAo::WriteFrame(CCsyMsgBufBpFrame* aBpFrame)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   227
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   228
 * This method is called to transmit a frame to the baseband.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   229
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   230
 * @param aBpFrame - Pointer to frame
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   231
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   232
    {
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   233
	_LOG_L4C2(">>CCommFrameWriterAo::WriteFrame [aBpFrame=0x%x]",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   234
		aBpFrame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   235
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   236
	TInt ret = KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   237
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   238
	iDlcNum = aBpFrame->MsgDlc();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   239
	iCompleteWhenSent = aBpFrame->CompleteWhenSent();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   240
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   241
	if (iBuf == NULL)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   242
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   243
		_LOG_L1C1("** Failure to alloc iBuf **");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   244
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   245
		ret = KErrNoMemory;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   246
		_LOG_L4C2("<<CCommFrameWriterAo::WriteFrame [ret=%d]",ret);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   247
		return ret;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   248
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   249
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   250
//*********************************************************
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   251
// MAF tidy up
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   252
#ifdef _DEBUG
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   253
	//log out frame
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   254
	TInt len = aBpFrame->iMsg.Length();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   255
	_LOG_L3C3("[0x%02x] Tx Got Start dlc=%d", aBpFrame->iMsg[0], aBpFrame->MsgDlc());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   256
	for(TInt k = 1; k < len-1; k++)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   257
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   258
		_LOG_L3C2("[0x%02x]",aBpFrame->iMsg[k]);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   259
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   260
	_LOG_L3C2("[0x%02x] Tx Frame End", aBpFrame->iMsg[len-1]);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   261
	if (iMux0710Protocol->IsMuxModeEnabled())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   262
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   263
		if ((aBpFrame->iMsg[2] & 0xEF) == KCsy0710CTLUIH)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   264
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   265
#ifdef __DEBUGLOGFILE__
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   266
			TBuf8<200> tt;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   267
#else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   268
			TBuf16<200> tt;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   269
#endif
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   270
			tt.Copy(aBpFrame->iMsg);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   271
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   272
			TInt ttLength = tt.Length();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   273
			tt.SetLength(ttLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   274
#ifdef __LOGDEBUGLEVELMINOR__
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   275
			_LOG_L3C3("Sent >>>> %d: %S", aBpFrame->iMsg[1] >> 2, &tt);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   276
#endif
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   277
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   278
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   279
#endif
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   280
//*********************************************************
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   281
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   282
	// copy message to local buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   283
#ifdef _27010ADVANCEOPTION
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   284
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   285
	if (iMux0710Protocol->IsMuxModeEnabled())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   286
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   287
		TInt length = aBpFrame->iMsg.Length() - 1;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   288
		TUint8 mask = 1<<5;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   289
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   290
		iBuf->Zero();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   291
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   292
		 // start flag
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   293
		iBuf->Append(aBpFrame->iMsg[0]);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   294
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   295
		// check data for flag or escape character
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   296
		for (TInt i=1; i < length; i++)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   297
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   298
			TUint8 tmp = aBpFrame->iMsg[i];
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   299
			if ((tmp == KCsy0710StartEndFlag)||(tmp== KCsy0710EscapeByte))
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   300
				{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   301
				_LOG_L3C1("Adding escape byte");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   302
				iBuf->Append(KCsy0710EscapeByte);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   303
				tmp = (TUint8) (tmp^mask);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   304
				}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   305
			iBuf->Append(tmp);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   306
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   307
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   308
		//ending flag
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   309
		iBuf->Append(aBpFrame->iMsg[length]);  
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   310
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   311
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   312
		iBuf->Copy(aBpFrame->iMsg);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   313
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   314
#else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   315
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   316
	// Basic option - no escape chars
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   317
	iBuf->Copy(aBpFrame->iMsg);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   318
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   319
#endif
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   320
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   321
	// free the caller's frame buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   322
	iMux0710Protocol->AddFrameFreeQ(aBpFrame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   323
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   324
	// invoke LDD
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   325
	_LOG_L3C1("Sending to LDD");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   326
	iStatus = KRequestPending; //MAF why is this being set to KRequestPending?
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   327
 	SetActive();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   328
	iCommPort->Write(iStatus, *iBuf, iBuf->Length());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   329
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   330
	_LOG_L4C2("<<CCommFrameWriterAo::WriteFrame [ret=%d]",ret);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   331
	return ret;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   332
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   333
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   334
void CCommFrameWriterAo::WriteCancel()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   335
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   336
 * Cancel the current write operation.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   337
 * @return void
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   338
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   339
    {
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   340
    _LOG_L4C1("CCommFrameWriterAo::WriteCancel");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   341
	Cancel();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   342
    }
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   343
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   344
void CCommFrameWriterAo::AddToWaitingToSendList(CCsyMsgBufBpFrame* aBpFrame, TBool aHighPriority)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   345
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   346
 * This method is called to by C32 Interface objects to add
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   347
 * the specified frame to the baseband queue.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   348
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   349
 * @param aBpFrame - Pointer to the frame buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   350
 * @param aHighPriority - Flag to indicate a high priority frame
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   351
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   352
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   353
	_LOG_L4C3(">>CCommFrameWriterAo::AddToWaitingToSendList [aBpFrame=0x%x,aHighPriority=%d]",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   354
		aBpFrame, aHighPriority);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   355
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   356
	if (aHighPriority)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   357
		iWriteFrameBufList.AddFirst(*aBpFrame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   358
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   359
		iWriteFrameBufList.AddLast(*aBpFrame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   360
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   361
	_LOG_L4C1("<<CCommFrameWriterAo::AddToWaitingToSendList");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   362
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   363
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   364
CCsyMsgBufBpFrame* CCommFrameWriterAo::GetFrameToWrite()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   365
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   366
 * This method checks the queue for a frame that needs to be sent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   367
 * to the baseband.  If there is a message then deque it from the queue and
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   368
 * return a pointer to it, else return NULL.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   369
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   370
 * @return Pointer to the frame to be written or NULL
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   371
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   372
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   373
	_LOG_L4C1(">>CCommFrameWriterAo::GetFrameToWrite");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   374
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   375
	CCsyMsgBufBpFrame* frame = NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   376
	if (!iWriteFrameBufList.IsEmpty())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   377
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   378
		frame = iWriteFrameBufList.First();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   379
		if (frame)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   380
			iWriteFrameBufList.Remove(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   381
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   382
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   383
	_LOG_L4C2("<<CCommFrameWriterAo::GetFrameToWrite [frame=0x%x]",frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   384
	return frame;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   385
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   386
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   387
void CCommFrameWriterAo::RemoveAnyDlcFramesOnWriteList(TUint8 aDlcNum, TBool aPlaceOnWaitList)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   388
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   389
 * This method transfers any frames on the write list from the dlc specified
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   390
 * to the waiting list.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   391
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   392
 * @param aDlcNum is the dlc number of the frames to move to the waiting list
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   393
 * @param aPlaceOnWaitList indicates whether to free the frame or place onto the
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   394
 *        wait list.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   395
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   396
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   397
	_LOG_L4C3(">>CCommFrameWriterAo::RemoveAnyDlcFramesOnWriteList [aDlcNum=%d, aPlaceOnWaitList=%d]",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   398
		aDlcNum,aPlaceOnWaitList);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   399
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   400
	if (iWriteFrameBufList.IsEmpty())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   401
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   402
		// No frames to transfer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   403
		_LOG_L4C1("No frames on write list");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   404
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   405
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   406
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   407
		CCsyMsgBufBpFrame* frame = NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   408
		iWriteFrameBufIter.SetToFirst();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   409
		while ((frame = iWriteFrameBufIter++) != NULL)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   410
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   411
			if (frame->GetDlcNum() == aDlcNum)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   412
				{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   413
				iWriteFrameBufList.Remove(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   414
				if (aPlaceOnWaitList)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   415
					{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   416
					_LOG_L4C1("Transferring frame to wait list");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   417
					iWaitingForFcOffList.AddLast(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   418
					}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   419
				else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   420
					{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   421
					// Adding frame to the free list
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   422
					iMux0710Protocol->AddFrameFreeQ(frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   423
					}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   424
				}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   425
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   426
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   427
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   428
	_LOG_L4C1("<<CCommFrameWriterAo::RemoveAnyDlcFramesOnWriteList");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   429
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   430
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   431
void CCommFrameWriterAo::RemoveAnyDlcFramesFromWaitList(TUint8 aDlcNum, TBool aPlaceOnWriteList)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   432
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   433
 * This method transfers any frames on the waiting list from the dlc specified
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   434
 * to the write list.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   435
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   436
 * @param aDlcNum is the dlc number of the frames to move to the write list
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   437
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   438
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   439
	_LOG_L4C3(">>CCommFrameWriterAo::RemoveAnyDlcFramesFromWaitList [aDlcNum=%d,aPlaceOnWriteList=%d]",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   440
		aDlcNum,aPlaceOnWriteList);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   441
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   442
	if (iWaitingForFcOffList.IsEmpty())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   443
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   444
		// No frames to transfer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   445
		_LOG_L4C1("No frames on waiting list");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   446
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   447
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   448
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   449
		TBool writeQueueWasEmpty = iWriteFrameBufList.IsEmpty();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   450
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   451
		CCsyMsgBufBpFrame* frame = NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   452
		iWaitingForFcOffIter.SetToFirst();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   453
		while ((frame = iWaitingForFcOffIter++) != NULL)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   454
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   455
			if (frame->GetDlcNum() == aDlcNum)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   456
				{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   457
				iWaitingForFcOffList.Remove(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   458
				if (aPlaceOnWriteList)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   459
					{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   460
					_LOG_L4C1("Transferring frame to write list");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   461
					iWriteFrameBufList.AddLast(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   462
					}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   463
				else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   464
					{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   465
					// Adding frame to the free list
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   466
					iMux0710Protocol->AddFrameFreeQ(frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   467
					}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   468
				}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   469
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   470
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   471
		if ((!iWriteFrameBufList.IsEmpty())&&(writeQueueWasEmpty)&&(!IsActive()))
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   472
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   473
			_LOG_L4C1("Write queue was empty and not active - triggering write");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   474
			frame = GetFrameToWrite();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   475
			TInt ret = WriteFrame(frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   476
			if (ret)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   477
				{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   478
				_LOG_L1C2("Write delayed frame failed [ret=%d]",ret);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   479
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   480
				// Place the failed frame back on the list.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   481
				iWriteFrameBufList.AddFirst(*frame);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   482
				}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   483
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   484
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   485
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   486
	_LOG_L4C1("<<CCommFrameWriterAo::RemoveAnyDlcFramesFromWaitList");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   487
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   488
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   489
void CCommFrameWriterAo::CompleteWrite(const TUint8 aDlcNum, TInt aStatus)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   490
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   491
 * This method calls the DLC port interface to complete the write request.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   492
 *
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   493
 * @param aDlcNum - DLC number of the port
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   494
 */
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   495
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   496
	_LOG_L4C3(">>CCommFrameWriterAo::CompleteWrite [aDlcNum=%d,aStatus=%d]",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   497
		aDlcNum,aStatus);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   498
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   499
	if (aDlcNum)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   500
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   501
		CPortC32InterfaceBase* port = iParent->FindPortC32Interface(aDlcNum);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   502
		if (port)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   503
			port->CompleteWriteRequest(aStatus);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   504
		else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   505
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   506
			_LOG_L1C2("** Port does not exist for aDlcNum=%d **",
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   507
				aDlcNum);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   508
			// MAF __ASSERT_DEBUG(EFalse,PANIC(KPanicIllegalState));
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   509
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   510
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   511
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   512
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   513
		// MAF tell mux control channel of send result
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   514
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   515
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   516
	_LOG_L4C1("<<CCommFrameWriterAo::CompleteWrite");
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   517
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   518