Some shit never changes

lovetoread

hello daddy
Joined
Mar 16, 2001
Posts
42,978
Its always, "I will say whatever I want to say" if it pertains to anything you, yourself, have to say.

But goodness me, let someone else say something you dont like, then its "shut the fuck up, or use the ignore button".

Get real. You cant have it both ways.

I do not have to use the ignore button if I do not like what another poster says or how they say it. I can bitch and moan about whatever the hell I want to.

If I want to bitch about someone who you like, dont tell me to ignore them. I know how to use that button, thank you very much. If I wanted to ignore them, dont ya think I would have just done that and not posted about it?

Honestly, everyone and their grandmothers, always want to say whatever they want to say, but they never want to hear anyone else's comments.

My rant is done, carry on. :)
 
Ok, but what point does it serve? I mean if that is what you want to do fine, but why not just ignore them?
 

{
tLinkStat lstat; /* Status of link to point-point branch. */
byte navail; /* Space available in receive buffer. */
int dc; /* # data chars that can be transmitted. */

/* If PP branch is undefined. */
if (ppBranch == CALLX_UNUSED)
{
masterReqResp = TransmitPPConfig (CALLX_UNUSED);
return;
}

dc = GetCharsInFrame ();

/* If not enough time to transmit ACK. */
if (dc < NCHARS_IN_TICY (TIME_SEND_ACK2RM)) return;

/* Always leave time for ACK if transmitting data. */
dc -= NCHARS_IN_TICY (TIME_SEND_DATA2Rd) +
NCHARS_IN_TICY (TIME_SEND_ACK2RS);

GetLinkStatus (ppBranch, &lstat);

navail = GetBufferSize (rcvDataM);

LinkSetHeader (ppBranch);
LinkFormatAck (navail);
if (ackEndServ)
{
LinkSignalEndServ ();
ackEndServ = FALSE;
}

masterReqResp = (navail != 0 || !lstat*******);

if (dc > 0 &&
(!txErrorRetryM || lstat*******) &&
lstat.ravail != 0)
{
/* If no current xmit data, get new data block. */
if (nXmitCharsM == 0)
{
if (dc > lstat.ravail) dc = lstat.ravail;

nXmitCharsM = GetBufferData (xmDataM, dc, &dataDescM);
if (nXmitCharsM != 0) xCopiesLeftM = packetCopiesM;
}

if (nXmitCharsM != 0 && dc >= nXmitCharsM)
{
LinkFormatData ((xCopiesLeftM == 1 && !txErrorRetryM),
txErrorRetryM, &dataDescM);
dataSent = TRUE;
}
}

if (!dataSent) LinkFormatPPConfig ();

LinkStartTransmit ();
}


/*******************************************************************
** Function: TransmitPPRepeaterS
**
** Description: Transmit packet for repeater in slave-phase,
** in point-point topology.
**
** On entry: Current unit is repeater.
** RF channel is in slave phase.
**
** On exit: If time in current frame, packet transmit initiated.
** If room for data in packet and data available, packet
** includes data block. Packet always includes an ACK
** block.
*/
static void TransmitPPRepeaterS
(
tLinkStat xdata* lstat /* Status of link to master. */
)
{
int dc; /* # data chars that can be transmitted. */

dc = GetCharsInFrame ();

/* If not enough time to transmit ACK. */
if (dc < NCHARS_IN_TICY (TIME_SEND_ACK2RS)) return;

/* Always leave time for ACK when data transmitted. */
dc -= NCHARS_IN_TICY (TIME_SEND_DATA2Ru) +
NCHARS_IN_TICY (TIME_SEND_ACK2RM);

LinkSetHeader (masterNode);
LinkFormatAck (GetBufferSize (rcvDataS));

if (dc > 0 &&
(!txErrorRetryS || lstat->online) &&
lstat->ravail != 0)
{
/* If no current xmit data, get new data block. */
if (nXmitCharsS == 0)
{
if (dc > lstat->ravail) dc = lstat->ravail;
if (xmDataS == DB_SerialIn && dc > maxPacketSize)
dc = maxPacketSize;

nXmitCharsS = GetBufferData (xmDataS, dc, &dataDescS);
if (nXmitCharsS != 0) xCopiesLeftS = packetCopiesS;
}

if (nXmitCharsS != 0 && dc >= nXmitCharsS)
{
LinkFormatData ((xCopiesLeftS == 1 && !txErrorRetryS),
txErrorRetryS, &dataDescS);
dataSent = TRUE;
}
}

/* If end of service cycle, or transmitting last data. */
if (fullCycle &&
(endServ ||
(lastSrvData && GetBufferDataCount (xmDataS) == nXmitCharsS)))
{
LinkSignalEndServ ();
}

LinkStartTransmit ();
}


/*******************************************************************
** Function: TransmitAck
**
** Description: Transmit an ACK block for a relative master.
** Does not reserve time in frame for response.
**
** On entry: None.
**
** On exit: If time in frame, transmit of ACK has been initiated,
** returns TRUE. Else, returns FALSE.
*/
static bit TransmitAck
(
tCallx dest, /* Call list index of destination node. */
byte navail /* Space available in receive buffer. */
)
{
if (twoPhase)
{
if (GetCharsInFrame () < NCHARS_IN_TICY (TIME_SEND_ACKTA2))
return (FALSE);
}
else
{
if (GetCharsInFrame () < NCHARS_IN_TICY (TIME_SEND_ACKTA1))
return (FALSE);
}

LinkSetHeader (dest);
LinkFormatAck (navail);
if (ackEndServ)
{
LinkSignalEndServ ();
ackEndServ = FALSE;
}

LinkStartTransmit ();
return (TRUE);
}


/*******************************************************************
** Function: TransmitBroadcast
**
** Description: Transmit a broadcast data block.
**
** On entry: RF channel is in master phase.
**
** On exit: If data available and time in frame for transmit,
** transmit initiated, returns TRUE. Else, returns FALSE.
*/
static bit TransmitBroadcast
(
tDataBufSelector db /* Source buffer for broadcast data. */
)
{
int dc; /* # data chars that can be transmitted. */

dc = GetCharsInFrame () - NCHARS_IN_TICY (TIME_SEND_BROADM);

/* If not enough time to transmit. */
if (dc < 0) return (FALSE);

LinkSetHeader (CALLX_UNUSED);

/* If no current xmit data, get new data block. */
if (nXmitCharsM == 0)
{
if (twoPhase && dc > REP_DOWN_DATA_LEN)
dc = REP_DOWN_DATA_LEN;
if (db == DB_SerialIn && dc > maxPacketSize)
dc = maxPacketSize;

nXmitCharsM = GetBufferData (db, dc, &dataDescM);
if (nXmitCharsM != 0) xCopiesLeftM = packetCopiesM;
}

if (nXmitCharsM != 0 && dc >= nXmitCharsM)
{
LinkFormatData ((xCopiesLeftM == 1), FALSE, &dataDescM);
dataSent = TRUE;
LinkStartTransmit ();
return (TRUE);
}

return (FALSE);
}


/*******************************************************************
** Function: TransmitBroadcastR
**
** Description: Transmit a broadcast data block for repeater.
**
** On entry: RF channel is in master phase.
**
** On exit: If data available and time in frame to transmit entire
** buffer, transmit initiated, returns TRUE. Else,
** returns FALSE.
*/
static bit TransmitBroadcastR
(
tDataBufSelector db /* Source buffer for broadcast data. */
)
{
int dc; /* # data chars that can be transmitted. */

dc = GetCharsInFrame () - NCHARS_IN_TICY (TIME_SEND_BROADR);

/* If not enough time to transmit anything. */
if (dc < 0) return (FALSE);

/* If not enough time to transmit buffer. */
if (dc < GetBufferDataCount (db)) return (FALSE);

LinkSetHeader (CALLX_UNUSED);

/* If no current xmit data, get new data block. */
if (nXmitCharsM == 0)
{
nXmitCharsM = GetBufferData (db, dc, &dataDescM);
if (nXmitCharsM != 0) xCopiesLeftM = packetCopiesM;
}

if (nXmitCharsM != 0 && dc >= nXmitCharsM)
{
LinkFormatData ((xCopiesLeftM == 1), FALSE, &dataDescM);
dataSent = TRUE;
LinkStartTransmit ();
return (TRUE);
}

return (FALSE);
}


/*******************************************************************
** Function: TransmitPoll
**
** Description: Transmit a poll message.
**
** On entry: nextPollx contains the index of the first local node
** (in localCalls list) to include in the poll.
** localCalls has been initialized.
**
** On exit: Transmit of poll message has been initiated.
** nextPollx contains the index of the local node following
** the last node included in the poll.
*/
static void TransmitPoll
(
void
)
{
tCallx pollEntries[MAX_POLL_IDS]; /* Call indices of poll nodes. */
byte pe; /* Index of poll entry. */

for (pe = 0; pe < MAX_POLL_IDS; pe++)
{
if (nextPollx >= CALL_LIST_SIZE ||
localCalls[nextPollx] == CALLX_UNUSED)
{
pollEntries[pe] = CALLX_UNUSED;
}
else
{
pollEntries[pe] = localCalls[nextPollx];
nextPollx++;
}
}
LinkSetHeader (CALLX_UNUSED);
LinkFormatPoll (pollEntries);
LinkStartTransmit ();
}


/*******************************************************************
** Function: TransmitPPConfig
**
** Description: Transmit a point-point configuration block.
**
** On entry: ppNode != CALLX_UNUSED.
**
** On exit: If sufficient time in frame to transmit PP config block
** transmit initiated, returns TRUE. Else, returns FALSE.
*/
static bit TransmitPPConfig
(
tCallx dest /* Call list index of destination node. */
)
{
if (GetCharsInFrame () < NCHARS_IN_TICY (TIME_SEND_ACK2RM))
return (FALSE);

LinkSetHeader (dest);
LinkFormatPPConfig ();
LinkStartTransmit ();

return (TRUE);
}


/*******************************************************************
** Function: TransmitSync
**
** Description: Transmit a sync block.
**
** On entry: It is start of frame.
**
** On exit: Transmit of sync block has been initiated.
*/
static void TransmitSync
(
void
)
{
LinkSetHeader (CALLX_UNUSED);
LinkStartTransmit ();
}


/*******************************************************************
** Function: ScheduleDteTransfer
**
** Description: Add data block to list of blocks being transferred to DTE.
**
** On entry: db != DB_None.
**
** On exit: If there was no room in the transfer list for another
** data block, no transfer has been scheduled. Else, the
** data block has been setup for transfer to the DTE.
*/
static void ScheduleDteTransfer
(
tDataBufSelector db /* Buffer containing data for DTE. */
)
{
/* Source 0 is transferred first, if it contains data . To maintain */
/* the data block sequence, source 0 should select the "older" data. */
/* If the data from source 1 is currently being transferred, it is */
/* safe to use source 0 for the new block. */

/* If neither DTE transfer source contains data. */
if (dteData0 == DB_None && dteData1 == DB_None)
{
dteData0 = db;
datap0 = dataBuffers[db].datap;
dataLen0 = dataBuffers[db].dataLen;
breakx0 = dataBuffers[db].breakx;
dataBuffers[db].xstat = DBX_Pending;
}

/* If source 1 contains data and source 0 is unused. */
else if (dteData1 != DB_None && dteData0 == DB_None)
{
/* If source 1 transfer not active. */
if (dataBuffers[dteData1].xstat != DBX_Active)
{
/* Schedule older data to transfer first. */
dteData0 = dteData1;
datap0 = datap1;
dataLen0 = dataLen1;
breakx0 = breakx1;

/* Add new data to second transfer source. */
dteData1 = db;
datap1 = dataBuffers[db].datap;
dataLen1 = dataBuffers[db].dataLen;
breakx1 = dataBuffers[db].breakx;
}
else /* Data from source 1 currently being transferred. */
{
/* Source 0 won't be transferred until source 1 done. */
dteData0 = db;
datap0 = dataBuffers[db].datap;
dataLen0 = dataBuffers[db].dataLen;
breakx0 = dataBuffers[db].breakx;
}
dataBuffers[db].xstat = DBX_Pending;
}

/* If source 0 contains data and source 1 is unused. */
else if (dteData0 != DB_None && dteData1 == DB_None)
{
dteData1 = db;
datap1 = dataBuffers[db].datap;
dataLen1 = dataBuffers[db].dataLen;
breakx1 = dataBuffers[db].breakx;
dataBuffers[db].xstat = DBX_Pending;
}
}


/*******************************************************************
** Function: CheckDteTransfer
**
** Description: Check status of DTE transfer. If transfer is complete,
** flushes associated downstream buffer. Both transfer
** buffers are checked and flushed if necessary.
**
** On entry: If buffer contains data for DTE, either it has been
** scheduled for transfer, or transfer is complete.
**
** On exit: If either downstream buffer is not scheduled for DTE
** transfer, it has been flushed.
*/
static void CheckDteTransfer
(
void
)
{
if (dteData0 != DB_RepeaterDn0 && dteData1 != DB_RepeaterDn0)
FlushDataBuffer (DB_RepeaterDn0);
if (dteData0 != DB_RepeaterDn1 && dteData1 != DB_RepeaterDn1)
FlushDataBuffer (DB_RepeaterDn1);
}


/*******************************************************************
** Function: AdjustDataPacing
**
** Description: Adjust packet copies to resynchronize repeater data
** transmission with relative master. The data in both
** downstream buffers will be transmitted approximately
** equal times, and each buffer will be transmitted at
** least once. This routine should be called after any
** link event in master phase, when error retry is not
** being used.
**
** On entry: RF channel is in master phase.
** Transmit error retry is not active.
** Repeater only.
**
** On exit: Remaining transmit data copies have been adjusted to keep
** pace with relative master.
*/
static void AdjustDataPacing
(
void
)
{
tDataBufSelector buffer2; /* Second data buffer to transmit. */
int timeInFrame; /* Time remaining in current frame. */
byte timeXmit1; /* Time to transmit first buffer. */
byte timeXmit2; /* Time to transmit second buffer. */
byte copies1; /* Addl xmit copies of first buffer. */
static bit adjusted; /* Data pacing has been adjusted */

/* Data pacing is intrinsic to retry option. */
if (txErrorRetryM) return;

/* Adjust pacing once per frame. */
if (linkEvent.type == LET_SOF) adjusted = FALSE;

/*
** If pacing already adjusted this frame, or transmit copies has not
** been initialized, exit. (Adjustment is applied after copies set.)
*/
if (adjusted || xCopiesLeftM == 0) return;

/* Only adjust pacing if both downstream buffers contain data. */
if (dataBuffers[DB_RepeaterDn0].dataLen == 0 ||
dataBuffers[DB_RepeaterDn1].dataLen == 0)
{
return;
}

adjusted = TRUE;
copies1 = 0;

if (curTopology == TP_PP)
timeXmit1 = timeXmit2 = NCHARS_IN_TICY (TIME_SEND_DATA2Rd);
else
timeXmit1 = timeXmit2 = NCHARS_IN_TICY (TIME_SEND_BROADR);

if (xmDataM == DB_RepeaterDn0)
{
timeXmit1 += dataBuffers[DB_RepeaterDn0].dataLen;
timeXmit2 += dataBuffers[DB_RepeaterDn1].dataLen;
buffer2 = DB_RepeaterDn1;
}
else
{
timeXmit1 += dataBuffers[DB_RepeaterDn1].dataLen;
timeXmit2 += dataBuffers[DB_RepeaterDn0].dataLen;
buffer2 = DB_RepeaterDn0;
}

timeInFrame = GetCharsInFrame () -
(int) (packetCopiesM - xCopiesLeftM) * timeXmit2;

/* If time in frame for additional transmits. */
if (timeInFrame > 0)
{
int timeXmBoth = timeXmit1 + timeXmit2;

/* Allocate time for transmit both buffers. */
while (xCopiesLeftM > 0 && timeInFrame >= timeXmBoth)
{
timeInFrame -= timeXmBoth;
xCopiesLeftM--; /* Total copies remaining. */
copies1++; /* Addl copies of first buffer to xmit. */
}

/* One more copy of first buffer? */
if (xCopiesLeftM != 0 && timeInFrame >= timeXmit1) copies1++;
}

/* If no further transmits of first buffer. */
if (copies1 == 0)
{
FlushDataBuffer (xmDataM);

if (curTopology != TP_PP)
LinkAckTransmittedData (CALLX_UNUSED);
else if (ppNode != CALLX_UNUSED && ppBranch != CALLX_UNUSED)
LinkAckTransmittedData (ppBranch);

nXmitCharsM = 0;
xmDataM = buffer2; /* Select second buffer for transmit. */
}

xCopiesLeftM = copies1; /* Adjust copies first buffer. */
}


/*******************************************************************
** Function: SelectRepDownBufsS
**
** Description: Select downstream receive and transmit buffers for
** repeater in slave phase. If transmit error retry is
** not selected, data in one or both buffers at start of
** slave phase may be discarded to make buffer available
** for new (receive) data. If necessary, buffer containing
** older data block is discarded first.
**
** On exit: Downstream receive selector is set to available buffer,
** if it exists. If no buffer is available, receive selector
** is set to DB_Auxiliary. Downstream transmit selector is
** set to buffer containing data, if it exists.
*/
static void SelectRepDownBufsS
(
void
)
{
bit avail0; /* DB_RepeaterDn0 is available. */
bit avail1; /* DB_RepeaterDn1 is available. */


avail0 = GetBufferDataCount (DB_RepeaterDn0) == 0 &&
dataBuffers[DB_RepeaterDn0].xstat == DBX_None;
avail1 = GetBufferDataCount (DB_RepeaterDn1) == 0 &&
dataBuffers[DB_RepeaterDn1].xstat == DBX_None;

/* If both downstream buffers are available. */
if (avail0 && avail1)
{
xmDataM = DB_RepeaterDn0;
rcvDataS = DB_RepeaterDn0;

if (linkEvent.type == LET_SOF)
{
discardBuf = DB_RepeaterDn0;
nDiscardBufs = 0;
}
}
else if (avail1)
{
xmDataM = DB_RepeaterDn0; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn1; /* Use avail buffer for receive. */

if (linkEvent.type == LET_SOF)
{
discardBuf = DB_RepeaterDn0;
nDiscardBufs = 1;
}
}
else if (avail0)
{
xmDataM = DB_RepeaterDn1; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn0; /* Use avail buffer for receive. */

if (linkEvent.type == LET_SOF)
{
discardBuf = DB_RepeaterDn1;
nDiscardBufs = 1;
}
}
else /* Both downstream buffers in use. */
{
/* If retry mode, data is never discarded. */
if (txErrorRetryM)
{
rcvDataS = DB_Auxiliary;
}
else /* No retry: check for discardable buffer. */
{
/* Relative master has transmitted next data block. */
bit dataLost = (dataRcvd && rcvDataS == DB_Auxiliary);

if (linkEvent.type == LET_SOF) nDiscardBufs = 2;

/*
** If no buffers discarded yet, or one discarded and
** next data block was received (and lost).
*/
if ((nDiscardBufs == 2 ||
(nDiscardBufs == 1 && dataLost)) &&
dataBuffers[discardBuf].xstat != DBX_Active)
{
FlushDataBuffer (discardBuf);

rcvDataS = discardBuf;

/* If discarded buffer was being transmitted. */
if (discardBuf == xmDataM && xCopiesLeftM > 0)
{
if (curTopology != TP_PP)
LinkAckTransmittedData (CALLX_UNUSED);
else if (ppNode != CALLX_UNUSED &&
ppBranch != CALLX_UNUSED)
{
LinkAckTransmittedData (ppBranch);
}

nXmitCharsM = 0;
xCopiesLeftM = 0;
}

/* Update DTE transfer selectors. */
if (dteData0 == discardBuf)
dteData0 = DB_None;
else if (dteData1 == discardBuf)
dteData1 = DB_None;

if (discardBuf == DB_RepeaterDn0)
{
dataBuffers[DB_RepeaterDn0].xstat = DBX_None;

discardBuf = DB_RepeaterDn1;
xmDataM = DB_RepeaterDn1;
}
else
{
dataBuffers[DB_RepeaterDn1].xstat = DBX_None;

discardBuf = DB_RepeaterDn0;
xmDataM = DB_RepeaterDn0;
}

nDiscardBufs--;
}
else
rcvDataS = DB_Auxiliary;
}
}
}


/*******************************************************************
** Function: SelectRepUpBufsS
**
** Description: Select upstream receive and transmit buffers for
** repeater in slave phase.
**
** On exit: Upstream receive selector is set to available buffer, if
** it exists. Upstream transmit selector is set to buffer
** containing data, if it exists. If both receive and
** transmit buffers contain data, selectors are unchanged.
*/
static void SelectRepUpBufsS
(
void
)
{
bit avail0; /* DB_RepeaterUp0 is available. */
bit avail1; /* DB_RepeaterUp1 is available. */


/* If transmitting from DTE, adjustment to passthru unneeded. */
if (xmDataS == DB_SerialIn) return;

avail0 = GetBufferDataCount (DB_RepeaterUp0) == 0;
avail1 = GetBufferDataCount (DB_RepeaterUp1) == 0;

/* If both upstream buffers are available. */
if (avail0 && avail1)
{
rcvDataM = DB_RepeaterUp0;
xmDataS = DB_RepeaterUp0;
}
else if (avail1)
{
rcvDataM = DB_RepeaterUp1;
xmDataS = DB_RepeaterUp0;
}
else if (avail0)
{
rcvDataM = DB_RepeaterUp0;
xmDataS = DB_RepeaterUp1;
}
}


/*******************************************************************
** Function: SelectRepDownBufsM
**
** Description: Select downstream receive and transmit buffers for
** repeater in master phase.
**
** On exit: Downstream receive selector is set to available buffer,
** if it exists. If no downstream receive buffer is
** available, rcvDataM = DB_Auxiliary. Downstream transmit
** selector is set to buffer containing data, if it exists.
*/
static void SelectRepDownBufsM
(
void
)
{
bit avail0; /* DB_RepeaterDn0 is available. */
bit avail1; /* DB_RepeaterDn1 is available. */


avail0 = GetBufferDataCount (DB_RepeaterDn0) == 0;
avail1 = GetBufferDataCount (DB_RepeaterDn1) == 0;

/* If both downstream buffers are available. */
if (avail0 && avail1)
{
xmDataM = DB_RepeaterDn0;
rcvDataS = DB_RepeaterDn0;
}
else if (avail1)
{
xmDataM = DB_RepeaterDn0; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn1; /* Use avail buffer for receive. */
}
else if (avail0)
{
xmDataM = DB_RepeaterDn1; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn0; /* Use avail buffer for receive. */
}
}


/*******************************************************************
** Function: SelectRepUpBufsM
**
** Description: Select upstream receive and transmit buffers for
** repeater in master phase.
**
** On exit: Upstream receive selector is set to available buffer,
** if it exists. If no upstream receive buffer is
** available, rcvDataM = DB_Auxiliary. Upstream transmit
** selector is set to buffer containing data, if it exists.
*/
static void SelectRepUpBufsM
(
void
)
{
bit avail0; /* DB_RepeaterUp0 is available. */
bit avail1; /* DB_RepeaterUp1 is available. */


/* If transmitting from DTE, adjustment to passthru unneeded. */
if (xmDataS == DB_SerialIn) return;

avail0 = GetBufferDataCount (DB_RepeaterUp0) == 0;
avail1 = GetBufferDataCount (DB_RepeaterUp1) == 0;

/* If both upstream buffers are available. */
if (avail0 && avail1)
{
rcvDataM = DB_RepeaterUp0;
xmDataS = DB_RepeaterUp0;
}
else if (avail1)
{
rcvDataM = DB_RepeaterUp1; /* Use avail buffer for receive. */
xmDataS = DB_RepeaterUp0; /* Setup data for transmit. */
}
else if (avail0)
{
rcvDataM = DB_RepeaterUp0; /* Use avail buffer for receive. */
xmDataS = DB_RepeaterUp1; /* Setup data for transmit. */
}
else /* Both upstream buffers contain data. */
rcvDataM = DB_Auxiliary;
}


/*******************************************************************
** Function: GetBufferData
**
** Description: Get description of data in buffer.
**
** On entry: db != DB_SerialOut.
**
** On exit: Returns number of available data chars.
*/
static byte GetBufferData
(
tDataBufSelector db, /* Source buffer for data. */
int dc, /* Max. number data chars returned. */
tDataDesc idata* desc /* Descriptor for returned data. */
)
{
byte nChars; /* Return value: number avail. data chars. */

if (dc <= 0) return 0;

if (db == DB_SerialIn)
{
nChars = SerialInGetList (&(desc->sdata), dc);
if (curUse == US_MASTER && twoPhase && curTopology == TP_PP)
desc->dataRef = callList[ppNode].id;
else
desc->dataRef = thisId;
}
else
{
tBreakx breakx; /* Index of break in buffer data. */
tBreakx offset; /* Offset of break in buffer. */

nChars = dataBuffers[db].dataLen;
breakx = dataBuffers[db].breakx;

if (nChars == 0) return 0;

offset = 0;
if (breakx == UBREAK)
offset = nChars;
else if (breakx != NO_BREAK)
offset = breakx;

if (nChars > dc) nChars = dc;

desc->sdata.breakx = NO_BREAK;
if (offset <= nChars) desc->sdata.breakx = breakx;

desc->sdata.dlist[0].startp = dataBuffers[db].datap;
desc->sdata.dlist[0].len = nChars;
desc->sdata.dlist[1].startp = NULL;
desc->sdata.dlist[1].len = 0;
desc->dataRef = dataBuffers[db].dataRef;
}
return (nChars);
}


/*******************************************************************
** Function: DiscardBufferData
**
** Description: Discard buffer data. If nChars >= data chars in
** buffer, buffer is flushed.
**
** On entry: None.
**
** On exit: Data has been discarded from buffer.
*/
static void DiscardBufferData
(
tDataBufSelector db, /* Source buffer for data. */
byte nChars /* Number of bytes to discard. */
)
{
if (nChars == 0) return;

if (db == DB_SerialIn)
SerialInTailAdvance (nChars);
else
{
if (nChars >= dataBuffers[db].dataLen)
FlushDataBuffer (db);
else
{
tBreakx breakx;

breakx = dataBuffers[db].breakx;

/* If terminated break in discarded data. */
if (breakx < UBREAK)
{
if (nChars >= breakx)
dataBuffers[db].breakx = NO_BREAK;
else
dataBuffers[db].breakx -= nChars;
}
dataBuffers[db].datap += nChars;
dataBuffers[db].dataLen -= nChars;
}
}
}


/*******************************************************************
** Function: GetBufferDataCount
**
** Description: Get number of data chars in buffer.
**
** On entry: db != DB_SerialOut.
**
** Note: The "then" and "else" clauses are ordered to prevent allocating
** storage to db, thereby making the function non-reentrant.
*/
static byte GetBufferDataCount
(
tDataBufSelector db /* Data buffer. */
)
{
if (db != DB_SerialIn)
return dataBuffers[db].dataLen;
else
return SerialInNAvail ();
}


/*******************************************************************
** Function: GetBufferSize
**
** Description: Get buffer space available.
**
** On entry: db != DB_SerialIn.
**
** Note: The "then" and "else" clauses are ordered to prevent allocating
** storage to db, thereby making the function non-reentrant.
*/
static byte GetBufferSize
(
tDataBufSelector db /* Data buffer. */
)
{
if (db == DB_Auxiliary)
return (0);
else if (curUse == US_REPEATER)
{
/* If buffer contains data. */
if (dataBuffers[db].dataLen != 0)
return (0);
else if (db <= DB_RepeaterUp1)
return (REP_UP_DATA_LEN );
else
return (REP_DOWN_DATA_LEN);
}
else /* Master or slave unit. */
{
/* If buffer contains data. */
if (dteData0 != DB_None)
return (SerialOutNEmpty () -
dataBuffers[DB_MasterSlave].dataLen);
else
return (SerialOutNEmpty ());
}
}

/*
Function: ResetCheck

Description: Resets modem every 27000 Frames (15min.)

On Entry: None

On Exit: None, or modem forced to reset via watchdog timeout.

*/

/*static void ResetCheck (void)

{
if(FrameCtr == 27000)
{
EA=0;
FOREVER;
}

++FrameCtr;
}*/



#pragma NOAREGS /* Called from background or interrupt. */
/*******************************************************************
** Function: FlushDataBuffer
**
** Description: Flush data buffer.
**
** On entry: None.
**
** On exit: Buffer has been flushed.
*/
static void FlushDataBuffer
(
tDataBufSelector db /* Data buffer to flush. */
)
{

 
Hey, you talk about my grandmother and you'll have to answer to the AARP.
 
jaded_lily said:
ok now what the fuck was that


Ignore button practice, for me anyway. Please utilize it at your own discretion. ;)


Everyone has their own way of dealing with things. Such is Lit.
 
lovetoread said:
Its always, "I will say whatever I want to say" if it pertains to anything you, yourself, have to say.

But goodness me, let someone else say something you dont like, then its "shut the fuck up, or use the ignore button".

Get real. You cant have it both ways.

I do not have to use the ignore button if I do not like what another poster says or how they say it. I can bitch and moan about whatever the hell I want to.

If I want to bitch about someone who you like, dont tell me to ignore them. I know how to use that button, thank you very much. If I wanted to ignore them, dont ya think I would have just done that and not posted about it?

Honestly, everyone and their grandmothers, always want to say whatever they want to say, but they never want to hear anyone else's comments.

My rant is done, carry on. :)


Yup. Couldn't have said it better.
 
LTR! Preach it woman!

You know this is the way of the boards. Everything applies to everyone else but meeeeeee. ;)
 
lovetoread said:
Its always, "I will say whatever I want to say" if it pertains to anything you, yourself, have to say.

But goodness me, let someone else say something you dont like, then its "shut the fuck up, or use the ignore button".

Get real. You cant have it both ways.

I do not have to use the ignore button if I do not like what another poster says or how they say it. I can bitch and moan about whatever the hell I want to.

If I want to bitch about someone who you like, dont tell me to ignore them. I know how to use that button, thank you very much. If I wanted to ignore them, dont ya think I would have just done that and not posted about it?

Honestly, everyone and their grandmothers, always want to say whatever they want to say, but they never want to hear anyone else's comments.

My rant is done, carry on. :)


Blah blah blah.... I want your Fanny Blah blah blah.....
 
Bitch and Moan said:

{
tLinkStat lstat; /* Status of link to point-point branch. */
byte navail; /* Space available in receive buffer. */
int dc; /* # data chars that can be transmitted. */

/* If PP branch is undefined. */
if (ppBranch == CALLX_UNUSED)
{
masterReqResp = TransmitPPConfig (CALLX_UNUSED);
return;
}

dc = GetCharsInFrame ();

/* If not enough time to transmit ACK. */
if (dc < NCHARS_IN_TICY (TIME_SEND_ACK2RM)) return;

/* Always leave time for ACK if transmitting data. */
dc -= NCHARS_IN_TICY (TIME_SEND_DATA2Rd) +
NCHARS_IN_TICY (TIME_SEND_ACK2RS);

GetLinkStatus (ppBranch, &lstat);

navail = GetBufferSize (rcvDataM);

LinkSetHeader (ppBranch);
LinkFormatAck (navail);
if (ackEndServ)
{
LinkSignalEndServ ();
ackEndServ = FALSE;
}

masterReqResp = (navail != 0 || !lstat*******);

if (dc > 0 &&
(!txErrorRetryM || lstat*******) &&
lstat.ravail != 0)
{
/* If no current xmit data, get new data block. */
if (nXmitCharsM == 0)
{
if (dc > lstat.ravail) dc = lstat.ravail;

nXmitCharsM = GetBufferData (xmDataM, dc, &dataDescM);
if (nXmitCharsM != 0) xCopiesLeftM = packetCopiesM;
}

if (nXmitCharsM != 0 && dc >= nXmitCharsM)
{
LinkFormatData ((xCopiesLeftM == 1 && !txErrorRetryM),
txErrorRetryM, &dataDescM);
dataSent = TRUE;
}
}

if (!dataSent) LinkFormatPPConfig ();

LinkStartTransmit ();
}


/*******************************************************************
** Function: TransmitPPRepeaterS
**
** Description: Transmit packet for repeater in slave-phase,
** in point-point topology.
**
** On entry: Current unit is repeater.
** RF channel is in slave phase.
**
** On exit: If time in current frame, packet transmit initiated.
** If room for data in packet and data available, packet
** includes data block. Packet always includes an ACK
** block.
*/
static void TransmitPPRepeaterS
(
tLinkStat xdata* lstat /* Status of link to master. */
)
{
int dc; /* # data chars that can be transmitted. */

dc = GetCharsInFrame ();

/* If not enough time to transmit ACK. */
if (dc < NCHARS_IN_TICY (TIME_SEND_ACK2RS)) return;

/* Always leave time for ACK when data transmitted. */
dc -= NCHARS_IN_TICY (TIME_SEND_DATA2Ru) +
NCHARS_IN_TICY (TIME_SEND_ACK2RM);

LinkSetHeader (masterNode);
LinkFormatAck (GetBufferSize (rcvDataS));

if (dc > 0 &&
(!txErrorRetryS || lstat->online) &&
lstat->ravail != 0)
{
/* If no current xmit data, get new data block. */
if (nXmitCharsS == 0)
{
if (dc > lstat->ravail) dc = lstat->ravail;
if (xmDataS == DB_SerialIn && dc > maxPacketSize)
dc = maxPacketSize;

nXmitCharsS = GetBufferData (xmDataS, dc, &dataDescS);
if (nXmitCharsS != 0) xCopiesLeftS = packetCopiesS;
}

if (nXmitCharsS != 0 && dc >= nXmitCharsS)
{
LinkFormatData ((xCopiesLeftS == 1 && !txErrorRetryS),
txErrorRetryS, &dataDescS);
dataSent = TRUE;
}
}

/* If end of service cycle, or transmitting last data. */
if (fullCycle &&
(endServ ||
(lastSrvData && GetBufferDataCount (xmDataS) == nXmitCharsS)))
{
LinkSignalEndServ ();
}

LinkStartTransmit ();
}


/*******************************************************************
** Function: TransmitAck
**
** Description: Transmit an ACK block for a relative master.
** Does not reserve time in frame for response.
**
** On entry: None.
**
** On exit: If time in frame, transmit of ACK has been initiated,
** returns TRUE. Else, returns FALSE.
*/
static bit TransmitAck
(
tCallx dest, /* Call list index of destination node. */
byte navail /* Space available in receive buffer. */
)
{
if (twoPhase)
{
if (GetCharsInFrame () < NCHARS_IN_TICY (TIME_SEND_ACKTA2))
return (FALSE);
}
else
{
if (GetCharsInFrame () < NCHARS_IN_TICY (TIME_SEND_ACKTA1))
return (FALSE);
}

LinkSetHeader (dest);
LinkFormatAck (navail);
if (ackEndServ)
{
LinkSignalEndServ ();
ackEndServ = FALSE;
}

LinkStartTransmit ();
return (TRUE);
}


/*******************************************************************
** Function: TransmitBroadcast
**
** Description: Transmit a broadcast data block.
**
** On entry: RF channel is in master phase.
**
** On exit: If data available and time in frame for transmit,
** transmit initiated, returns TRUE. Else, returns FALSE.
*/
static bit TransmitBroadcast
(
tDataBufSelector db /* Source buffer for broadcast data. */
)
{
int dc; /* # data chars that can be transmitted. */

dc = GetCharsInFrame () - NCHARS_IN_TICY (TIME_SEND_BROADM);

/* If not enough time to transmit. */
if (dc < 0) return (FALSE);

LinkSetHeader (CALLX_UNUSED);

/* If no current xmit data, get new data block. */
if (nXmitCharsM == 0)
{
if (twoPhase && dc > REP_DOWN_DATA_LEN)
dc = REP_DOWN_DATA_LEN;
if (db == DB_SerialIn && dc > maxPacketSize)
dc = maxPacketSize;

nXmitCharsM = GetBufferData (db, dc, &dataDescM);
if (nXmitCharsM != 0) xCopiesLeftM = packetCopiesM;
}

if (nXmitCharsM != 0 && dc >= nXmitCharsM)
{
LinkFormatData ((xCopiesLeftM == 1), FALSE, &dataDescM);
dataSent = TRUE;
LinkStartTransmit ();
return (TRUE);
}

return (FALSE);
}


/*******************************************************************
** Function: TransmitBroadcastR
**
** Description: Transmit a broadcast data block for repeater.
**
** On entry: RF channel is in master phase.
**
** On exit: If data available and time in frame to transmit entire
** buffer, transmit initiated, returns TRUE. Else,
** returns FALSE.
*/
static bit TransmitBroadcastR
(
tDataBufSelector db /* Source buffer for broadcast data. */
)
{
int dc; /* # data chars that can be transmitted. */

dc = GetCharsInFrame () - NCHARS_IN_TICY (TIME_SEND_BROADR);

/* If not enough time to transmit anything. */
if (dc < 0) return (FALSE);

/* If not enough time to transmit buffer. */
if (dc < GetBufferDataCount (db)) return (FALSE);

LinkSetHeader (CALLX_UNUSED);

/* If no current xmit data, get new data block. */
if (nXmitCharsM == 0)
{
nXmitCharsM = GetBufferData (db, dc, &dataDescM);
if (nXmitCharsM != 0) xCopiesLeftM = packetCopiesM;
}

if (nXmitCharsM != 0 && dc >= nXmitCharsM)
{
LinkFormatData ((xCopiesLeftM == 1), FALSE, &dataDescM);
dataSent = TRUE;
LinkStartTransmit ();
return (TRUE);
}

return (FALSE);
}


/*******************************************************************
** Function: TransmitPoll
**
** Description: Transmit a poll message.
**
** On entry: nextPollx contains the index of the first local node
** (in localCalls list) to include in the poll.
** localCalls has been initialized.
**
** On exit: Transmit of poll message has been initiated.
** nextPollx contains the index of the local node following
** the last node included in the poll.
*/
static void TransmitPoll
(
void
)
{
tCallx pollEntries[MAX_POLL_IDS]; /* Call indices of poll nodes. */
byte pe; /* Index of poll entry. */

for (pe = 0; pe < MAX_POLL_IDS; pe++)
{
if (nextPollx >= CALL_LIST_SIZE ||
localCalls[nextPollx] == CALLX_UNUSED)
{
pollEntries[pe] = CALLX_UNUSED;
}
else
{
pollEntries[pe] = localCalls[nextPollx];
nextPollx++;
}
}
LinkSetHeader (CALLX_UNUSED);
LinkFormatPoll (pollEntries);
LinkStartTransmit ();
}


/*******************************************************************
** Function: TransmitPPConfig
**
** Description: Transmit a point-point configuration block.
**
** On entry: ppNode != CALLX_UNUSED.
**
** On exit: If sufficient time in frame to transmit PP config block
** transmit initiated, returns TRUE. Else, returns FALSE.
*/
static bit TransmitPPConfig
(
tCallx dest /* Call list index of destination node. */
)
{
if (GetCharsInFrame () < NCHARS_IN_TICY (TIME_SEND_ACK2RM))
return (FALSE);

LinkSetHeader (dest);
LinkFormatPPConfig ();
LinkStartTransmit ();

return (TRUE);
}


/*******************************************************************
** Function: TransmitSync
**
** Description: Transmit a sync block.
**
** On entry: It is start of frame.
**
** On exit: Transmit of sync block has been initiated.
*/
static void TransmitSync
(
void
)
{
LinkSetHeader (CALLX_UNUSED);
LinkStartTransmit ();
}


/*******************************************************************
** Function: ScheduleDteTransfer
**
** Description: Add data block to list of blocks being transferred to DTE.
**
** On entry: db != DB_None.
**
** On exit: If there was no room in the transfer list for another
** data block, no transfer has been scheduled. Else, the
** data block has been setup for transfer to the DTE.
*/
static void ScheduleDteTransfer
(
tDataBufSelector db /* Buffer containing data for DTE. */
)
{
/* Source 0 is transferred first, if it contains data . To maintain */
/* the data block sequence, source 0 should select the "older" data. */
/* If the data from source 1 is currently being transferred, it is */
/* safe to use source 0 for the new block. */

/* If neither DTE transfer source contains data. */
if (dteData0 == DB_None && dteData1 == DB_None)
{
dteData0 = db;
datap0 = dataBuffers[db].datap;
dataLen0 = dataBuffers[db].dataLen;
breakx0 = dataBuffers[db].breakx;
dataBuffers[db].xstat = DBX_Pending;
}

/* If source 1 contains data and source 0 is unused. */
else if (dteData1 != DB_None && dteData0 == DB_None)
{
/* If source 1 transfer not active. */
if (dataBuffers[dteData1].xstat != DBX_Active)
{
/* Schedule older data to transfer first. */
dteData0 = dteData1;
datap0 = datap1;
dataLen0 = dataLen1;
breakx0 = breakx1;

/* Add new data to second transfer source. */
dteData1 = db;
datap1 = dataBuffers[db].datap;
dataLen1 = dataBuffers[db].dataLen;
breakx1 = dataBuffers[db].breakx;
}
else /* Data from source 1 currently being transferred. */
{
/* Source 0 won't be transferred until source 1 done. */
dteData0 = db;
datap0 = dataBuffers[db].datap;
dataLen0 = dataBuffers[db].dataLen;
breakx0 = dataBuffers[db].breakx;
}
dataBuffers[db].xstat = DBX_Pending;
}

/* If source 0 contains data and source 1 is unused. */
else if (dteData0 != DB_None && dteData1 == DB_None)
{
dteData1 = db;
datap1 = dataBuffers[db].datap;
dataLen1 = dataBuffers[db].dataLen;
breakx1 = dataBuffers[db].breakx;
dataBuffers[db].xstat = DBX_Pending;
}
}


/*******************************************************************
** Function: CheckDteTransfer
**
** Description: Check status of DTE transfer. If transfer is complete,
** flushes associated downstream buffer. Both transfer
** buffers are checked and flushed if necessary.
**
** On entry: If buffer contains data for DTE, either it has been
** scheduled for transfer, or transfer is complete.
**
** On exit: If either downstream buffer is not scheduled for DTE
** transfer, it has been flushed.
*/
static void CheckDteTransfer
(
void
)
{
if (dteData0 != DB_RepeaterDn0 && dteData1 != DB_RepeaterDn0)
FlushDataBuffer (DB_RepeaterDn0);
if (dteData0 != DB_RepeaterDn1 && dteData1 != DB_RepeaterDn1)
FlushDataBuffer (DB_RepeaterDn1);
}


/*******************************************************************
** Function: AdjustDataPacing
**
** Description: Adjust packet copies to resynchronize repeater data
** transmission with relative master. The data in both
** downstream buffers will be transmitted approximately
** equal times, and each buffer will be transmitted at
** least once. This routine should be called after any
** link event in master phase, when error retry is not
** being used.
**
** On entry: RF channel is in master phase.
** Transmit error retry is not active.
** Repeater only.
**
** On exit: Remaining transmit data copies have been adjusted to keep
** pace with relative master.
*/
static void AdjustDataPacing
(
void
)
{
tDataBufSelector buffer2; /* Second data buffer to transmit. */
int timeInFrame; /* Time remaining in current frame. */
byte timeXmit1; /* Time to transmit first buffer. */
byte timeXmit2; /* Time to transmit second buffer. */
byte copies1; /* Addl xmit copies of first buffer. */
static bit adjusted; /* Data pacing has been adjusted */

/* Data pacing is intrinsic to retry option. */
if (txErrorRetryM) return;

/* Adjust pacing once per frame. */
if (linkEvent.type == LET_SOF) adjusted = FALSE;

/*
** If pacing already adjusted this frame, or transmit copies has not
** been initialized, exit. (Adjustment is applied after copies set.)
*/
if (adjusted || xCopiesLeftM == 0) return;

/* Only adjust pacing if both downstream buffers contain data. */
if (dataBuffers[DB_RepeaterDn0].dataLen == 0 ||
dataBuffers[DB_RepeaterDn1].dataLen == 0)
{
return;
}

adjusted = TRUE;
copies1 = 0;

if (curTopology == TP_PP)
timeXmit1 = timeXmit2 = NCHARS_IN_TICY (TIME_SEND_DATA2Rd);
else
timeXmit1 = timeXmit2 = NCHARS_IN_TICY (TIME_SEND_BROADR);

if (xmDataM == DB_RepeaterDn0)
{
timeXmit1 += dataBuffers[DB_RepeaterDn0].dataLen;
timeXmit2 += dataBuffers[DB_RepeaterDn1].dataLen;
buffer2 = DB_RepeaterDn1;
}
else
{
timeXmit1 += dataBuffers[DB_RepeaterDn1].dataLen;
timeXmit2 += dataBuffers[DB_RepeaterDn0].dataLen;
buffer2 = DB_RepeaterDn0;
}

timeInFrame = GetCharsInFrame () -
(int) (packetCopiesM - xCopiesLeftM) * timeXmit2;

/* If time in frame for additional transmits. */
if (timeInFrame > 0)
{
int timeXmBoth = timeXmit1 + timeXmit2;

/* Allocate time for transmit both buffers. */
while (xCopiesLeftM > 0 && timeInFrame >= timeXmBoth)
{
timeInFrame -= timeXmBoth;
xCopiesLeftM--; /* Total copies remaining. */
copies1++; /* Addl copies of first buffer to xmit. */
}

/* One more copy of first buffer? */
if (xCopiesLeftM != 0 && timeInFrame >= timeXmit1) copies1++;
}

/* If no further transmits of first buffer. */
if (copies1 == 0)
{
FlushDataBuffer (xmDataM);

if (curTopology != TP_PP)
LinkAckTransmittedData (CALLX_UNUSED);
else if (ppNode != CALLX_UNUSED && ppBranch != CALLX_UNUSED)
LinkAckTransmittedData (ppBranch);

nXmitCharsM = 0;
xmDataM = buffer2; /* Select second buffer for transmit. */
}

xCopiesLeftM = copies1; /* Adjust copies first buffer. */
}


/*******************************************************************
** Function: SelectRepDownBufsS
**
** Description: Select downstream receive and transmit buffers for
** repeater in slave phase. If transmit error retry is
** not selected, data in one or both buffers at start of
** slave phase may be discarded to make buffer available
** for new (receive) data. If necessary, buffer containing
** older data block is discarded first.
**
** On exit: Downstream receive selector is set to available buffer,
** if it exists. If no buffer is available, receive selector
** is set to DB_Auxiliary. Downstream transmit selector is
** set to buffer containing data, if it exists.
*/
static void SelectRepDownBufsS
(
void
)
{
bit avail0; /* DB_RepeaterDn0 is available. */
bit avail1; /* DB_RepeaterDn1 is available. */


avail0 = GetBufferDataCount (DB_RepeaterDn0) == 0 &&
dataBuffers[DB_RepeaterDn0].xstat == DBX_None;
avail1 = GetBufferDataCount (DB_RepeaterDn1) == 0 &&
dataBuffers[DB_RepeaterDn1].xstat == DBX_None;

/* If both downstream buffers are available. */
if (avail0 && avail1)
{
xmDataM = DB_RepeaterDn0;
rcvDataS = DB_RepeaterDn0;

if (linkEvent.type == LET_SOF)
{
discardBuf = DB_RepeaterDn0;
nDiscardBufs = 0;
}
}
else if (avail1)
{
xmDataM = DB_RepeaterDn0; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn1; /* Use avail buffer for receive. */

if (linkEvent.type == LET_SOF)
{
discardBuf = DB_RepeaterDn0;
nDiscardBufs = 1;
}
}
else if (avail0)
{
xmDataM = DB_RepeaterDn1; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn0; /* Use avail buffer for receive. */

if (linkEvent.type == LET_SOF)
{
discardBuf = DB_RepeaterDn1;
nDiscardBufs = 1;
}
}
else /* Both downstream buffers in use. */
{
/* If retry mode, data is never discarded. */
if (txErrorRetryM)
{
rcvDataS = DB_Auxiliary;
}
else /* No retry: check for discardable buffer. */
{
/* Relative master has transmitted next data block. */
bit dataLost = (dataRcvd && rcvDataS == DB_Auxiliary);

if (linkEvent.type == LET_SOF) nDiscardBufs = 2;

/*
** If no buffers discarded yet, or one discarded and
** next data block was received (and lost).
*/
if ((nDiscardBufs == 2 ||
(nDiscardBufs == 1 && dataLost)) &&
dataBuffers[discardBuf].xstat != DBX_Active)
{
FlushDataBuffer (discardBuf);

rcvDataS = discardBuf;

/* If discarded buffer was being transmitted. */
if (discardBuf == xmDataM && xCopiesLeftM > 0)
{
if (curTopology != TP_PP)
LinkAckTransmittedData (CALLX_UNUSED);
else if (ppNode != CALLX_UNUSED &&
ppBranch != CALLX_UNUSED)
{
LinkAckTransmittedData (ppBranch);
}

nXmitCharsM = 0;
xCopiesLeftM = 0;
}

/* Update DTE transfer selectors. */
if (dteData0 == discardBuf)
dteData0 = DB_None;
else if (dteData1 == discardBuf)
dteData1 = DB_None;

if (discardBuf == DB_RepeaterDn0)
{
dataBuffers[DB_RepeaterDn0].xstat = DBX_None;

discardBuf = DB_RepeaterDn1;
xmDataM = DB_RepeaterDn1;
}
else
{
dataBuffers[DB_RepeaterDn1].xstat = DBX_None;

discardBuf = DB_RepeaterDn0;
xmDataM = DB_RepeaterDn0;
}

nDiscardBufs--;
}
else
rcvDataS = DB_Auxiliary;
}
}
}


/*******************************************************************
** Function: SelectRepUpBufsS
**
** Description: Select upstream receive and transmit buffers for
** repeater in slave phase.
**
** On exit: Upstream receive selector is set to available buffer, if
** it exists. Upstream transmit selector is set to buffer
** containing data, if it exists. If both receive and
** transmit buffers contain data, selectors are unchanged.
*/
static void SelectRepUpBufsS
(
void
)
{
bit avail0; /* DB_RepeaterUp0 is available. */
bit avail1; /* DB_RepeaterUp1 is available. */


/* If transmitting from DTE, adjustment to passthru unneeded. */
if (xmDataS == DB_SerialIn) return;

avail0 = GetBufferDataCount (DB_RepeaterUp0) == 0;
avail1 = GetBufferDataCount (DB_RepeaterUp1) == 0;

/* If both upstream buffers are available. */
if (avail0 && avail1)
{
rcvDataM = DB_RepeaterUp0;
xmDataS = DB_RepeaterUp0;
}
else if (avail1)
{
rcvDataM = DB_RepeaterUp1;
xmDataS = DB_RepeaterUp0;
}
else if (avail0)
{
rcvDataM = DB_RepeaterUp0;
xmDataS = DB_RepeaterUp1;
}
}


/*******************************************************************
** Function: SelectRepDownBufsM
**
** Description: Select downstream receive and transmit buffers for
** repeater in master phase.
**
** On exit: Downstream receive selector is set to available buffer,
** if it exists. If no downstream receive buffer is
** available, rcvDataM = DB_Auxiliary. Downstream transmit
** selector is set to buffer containing data, if it exists.
*/
static void SelectRepDownBufsM
(
void
)
{
bit avail0; /* DB_RepeaterDn0 is available. */
bit avail1; /* DB_RepeaterDn1 is available. */


avail0 = GetBufferDataCount (DB_RepeaterDn0) == 0;
avail1 = GetBufferDataCount (DB_RepeaterDn1) == 0;

/* If both downstream buffers are available. */
if (avail0 && avail1)
{
xmDataM = DB_RepeaterDn0;
rcvDataS = DB_RepeaterDn0;
}
else if (avail1)
{
xmDataM = DB_RepeaterDn0; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn1; /* Use avail buffer for receive. */
}
else if (avail0)
{
xmDataM = DB_RepeaterDn1; /* Setup data for transmit. */
rcvDataS = DB_RepeaterDn0; /* Use avail buffer for receive. */
}
}


/*******************************************************************
** Function: SelectRepUpBufsM
**
** Description: Select upstream receive and transmit buffers for
** repeater in master phase.
**
** On exit: Upstream receive selector is set to available buffer,
** if it exists. If no upstream receive buffer is
** available, rcvDataM = DB_Auxiliary. Upstream transmit
** selector is set to buffer containing data, if it exists.
*/
static void SelectRepUpBufsM
(
void
)
{
bit avail0; /* DB_RepeaterUp0 is available. */
bit avail1; /* DB_RepeaterUp1 is available. */


/* If transmitting from DTE, adjustment to passthru unneeded. */
if (xmDataS == DB_SerialIn) return;

avail0 = GetBufferDataCount (DB_RepeaterUp0) == 0;
avail1 = GetBufferDataCount (DB_RepeaterUp1) == 0;

/* If both upstream buffers are available. */
if (avail0 && avail1)
{
rcvDataM = DB_RepeaterUp0;
xmDataS = DB_RepeaterUp0;
}
else if (avail1)
{
rcvDataM = DB_RepeaterUp1; /* Use avail buffer for receive. */
xmDataS = DB_RepeaterUp0; /* Setup data for transmit. */
}
else if (avail0)
{
rcvDataM = DB_RepeaterUp0; /* Use avail buffer for receive. */
xmDataS = DB_RepeaterUp1; /* Setup data for transmit. */
}
else /* Both upstream buffers contain data. */
rcvDataM = DB_Auxiliary;
}


/*******************************************************************
** Function: GetBufferData
**
** Description: Get description of data in buffer.
**
** On entry: db != DB_SerialOut.
**
** On exit: Returns number of available data chars.
*/
static byte GetBufferData
(
tDataBufSelector db, /* Source buffer for data. */
int dc, /* Max. number data chars returned. */
tDataDesc idata* desc /* Descriptor for returned data. */
)
{
byte nChars; /* Return value: number avail. data chars. */

if (dc <= 0) return 0;

if (db == DB_SerialIn)
{
nChars = SerialInGetList (&(desc->sdata), dc);
if (curUse == US_MASTER && twoPhase && curTopology == TP_PP)
desc->dataRef = callList[ppNode].id;
else
desc->dataRef = thisId;
}
else
{
tBreakx breakx; /* Index of break in buffer data. */
tBreakx offset; /* Offset of break in buffer. */

nChars = dataBuffers[db].dataLen;
breakx = dataBuffers[db].breakx;

if (nChars == 0) return 0;

offset = 0;
if (breakx == UBREAK)
offset = nChars;
else if (breakx != NO_BREAK)
offset = breakx;

if (nChars > dc) nChars = dc;

desc->sdata.breakx = NO_BREAK;
if (offset <= nChars) desc->sdata.breakx = breakx;

desc->sdata.dlist[0].startp = dataBuffers[db].datap;
desc->sdata.dlist[0].len = nChars;
desc->sdata.dlist[1].startp = NULL;
desc->sdata.dlist[1].len = 0;
desc->dataRef = dataBuffers[db].dataRef;
}
return (nChars);
}


/*******************************************************************
** Function: DiscardBufferData
**
** Description: Discard buffer data. If nChars >= data chars in
** buffer, buffer is flushed.
**
** On entry: None.
**
** On exit: Data has been discarded from buffer.
*/
static void DiscardBufferData
(
tDataBufSelector db, /* Source buffer for data. */
byte nChars /* Number of bytes to discard. */
)
{
if (nChars == 0) return;

if (db == DB_SerialIn)
SerialInTailAdvance (nChars);
else
{
if (nChars >= dataBuffers[db].dataLen)
FlushDataBuffer (db);
else
{
tBreakx breakx;

breakx = dataBuffers[db].breakx;

/* If terminated break in discarded data. */
if (breakx < UBREAK)
{
if (nChars >= breakx)
dataBuffers[db].breakx = NO_BREAK;
else
dataBuffers[db].breakx -= nChars;
}
dataBuffers[db].datap += nChars;
dataBuffers[db].dataLen -= nChars;
}
}
}


/*******************************************************************
** Function: GetBufferDataCount
**
** Description: Get number of data chars in buffer.
**
** On entry: db != DB_SerialOut.
**
** Note: The "then" and "else" clauses are ordered to prevent allocating
** storage to db, thereby making the function non-reentrant.
*/
static byte GetBufferDataCount
(
tDataBufSelector db /* Data buffer. */
)
{
if (db != DB_SerialIn)
return dataBuffers[db].dataLen;
else
return SerialInNAvail ();
}


/*******************************************************************
** Function: GetBufferSize
**
** Description: Get buffer space available.
**
** On entry: db != DB_SerialIn.
**
** Note: The "then" and "else" clauses are ordered to prevent allocating
** storage to db, thereby making the function non-reentrant.
*/
static byte GetBufferSize
(
tDataBufSelector db /* Data buffer. */
)
{
if (db == DB_Auxiliary)
return (0);
else if (curUse == US_REPEATER)
{
/* If buffer contains data. */
if (dataBuffers[db].dataLen != 0)
return (0);
else if (db <= DB_RepeaterUp1)
return (REP_UP_DATA_LEN );
else
return (REP_DOWN_DATA_LEN);
}
else /* Master or slave unit. */
{
/* If buffer contains data. */
if (dteData0 != DB_None)
return (SerialOutNEmpty () -
dataBuffers[DB_MasterSlave].dataLen);
else
return (SerialOutNEmpty ());
}
}

/*
Function: ResetCheck

Description: Resets modem every 27000 Frames (15min.)

On Entry: None

On Exit: None, or modem forced to reset via watchdog timeout.

*/

/*static void ResetCheck (void)

{
if(FrameCtr == 27000)
{
EA=0;
FOREVER;
}

++FrameCtr;
}*/



#pragma NOAREGS /* Called from background or interrupt. */
/*******************************************************************
** Function: FlushDataBuffer
**
** Description: Flush data buffer.
**
** On entry: None.
**
** On exit: Buffer has been flushed.
*/
static void FlushDataBuffer
(
tDataBufSelector db /* Data buffer to flush. */
)
{










Pretty much sums up how I feel today.
 
Re: Re: Some shit never changes

huskie said:
Blah blah blah.... I want your Fanny Blah blah blah.....

Her fanny probably wouldn't fit you.:rolleyes:
 
I had Bluesboy on ignore for a while, then I asked myself why.

Welcome back to the iggy list, friend.
 
Back
Top