Skip to content

Commit

Permalink
New method: NetSocket::get()
Browse files Browse the repository at this point in the history
  • Loading branch information
ThBreuer committed Jun 25, 2024
1 parent 5cc3ea8 commit 904349f
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Src/Hardware/Common/Net/Eth/NetEthTCP.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ class NetEthTCP : public NetEthTransport
//-----------------------------------------------------------
virtual bool get( BYTE &x );

//-----------------------------------------------------------
virtual DataPointer get( WORD maxLen );

//-----------------------------------------------------------
virtual DataPointer getDataPointer( void );

Expand Down
16 changes: 16 additions & 0 deletions Src/Hardware/Common/Net/Eth/NetEthUDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ bool NetEthUDP::Socket::get( BYTE &x )
return( false );
}

//-------------------------------------------------------------------
DataPointer NetEthUDP::Socket::get( WORD maxLen )
{
DataPointer dp;
if( stateLocal == OPEN || stateLocal == LISTEN )
{
if( udp.inPos < udp.inBufLen )
{
WORD minLen = MIN( (WORD)(udp.inBufLen-udp.inPos), dp.getSize() );
dp = DataPointer( (BYTE*)&udp.buf[udp.inPos], minLen);
udp.inPos += minLen;
}
}
return( dp );
}

//-------------------------------------------------------------------
DataPointer NetEthUDP::Socket::getDataPointer( void )
{
Expand Down
3 changes: 3 additions & 0 deletions Src/Hardware/Common/Net/Eth/NetEthUDP.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class NetEthUDP : public NetEthTransport
//-----------------------------------------------------------
virtual bool get( BYTE &x );

//-----------------------------------------------------------
virtual DataPointer get( WORD maxLen );

//-----------------------------------------------------------
virtual DataPointer getDataPointer( void );

Expand Down
6 changes: 6 additions & 0 deletions Src/Hardware/Common/Net/NetSocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ class NetSocket : protected Net::Task
*/
virtual bool get( BYTE &x ) = 0;

//---------------------------------------------------------------
/*! todo comment
\return ...
*/
virtual DataPointer get( WORD maxLen ) = 0;

//---------------------------------------------------------------
/*! Get the DataPointer of the outgoing data buffer
\return DataPointer
Expand Down
13 changes: 13 additions & 0 deletions Src/Hardware/MCU/Virtual/Src/NetWin.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ class NetWin : public Net
return( false );
}

//-------------------------------------------------------------------
virtual DataPointer get( WORD maxLen )
{
DataPointer dp;
if( net.bufIdx < net.bufLen )
{
WORD minLen = MIN( (WORD)(net.bufLen-net.bufIdx), maxLen );
dp = DataPointer( (BYTE*)&net.buf[net.bufIdx], minLen);
net.bufIdx += minLen;
}
return( dp );
}

//-----------------------------------------------------------
virtual DataPointer getDataPointer( void )
{
Expand Down

0 comments on commit 904349f

Please sign in to comment.