muy currado yo estudié redes neuronales en la carrera y no tiene nada que ver la orientación que se le da en practicas y teoria con las aplicaciones que puede tener
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú
/* ----------------------- Prototypes 0-------------------------------------*/
typedef void ( *pvMBFrameStart ) ( void );
typedef void ( *pvMBFrameStop ) ( void );
typedef eMBErrorCode( *peMBFrameReceive ) ( UCHAR * pucRcvAddress,
UCHAR ** pucFrame,
USHORT * pusLength );
typedef eMBErrorCode( *peMBFrameSend ) ( UCHAR slaveAddress,
const UCHAR * pucFrame,
USHORT usLength );
typedef void( *pvMBFrameClose ) ( void );
/* Functions pointer which are initialized in eMBInit( ). Depending on the
* mode (RTU or ASCII) the are set to the correct implementations.
*/
static peMBFrameSend peMBFrameSendCur;
static pvMBFrameStart pvMBFrameStartCur;
static pvMBFrameStop pvMBFrameStopCur;
static peMBFrameReceive peMBFrameReceiveCur;
static pvMBFrameClose pvMBFrameCloseCur;
eMBErrorCode
eMBPoll( void ) {
static UCHAR *ucMBFrame;
static UCHAR ucRcvAddress;
static UCHAR ucFunctionCode;
static USHORT usLength;
static eMBException eException;
int i;
eMBErrorCode eStatus = MB_ENOERR;
eMBEventType eEvent;
/* Check if the protocol stack is ready. */
if ( eMBState != STATE_ENABLED ) {
return MB_EILLSTATE;
}
/* Check if there is a event available. If not return control to caller.
* Otherwise we will handle the event. */
if ( xMBPortEventGet( &eEvent ) == TRUE ) {
switch ( eEvent ) {
case EV_READY:
break;
case EV_FRAME_RECEIVED:
eStatus = peMBFrameReceiveCur( &ucRcvAddress, &ucMBFrame, &usLength );
if ( eStatus == MB_ENOERR ) {
/* Check if the frame is for us. If not ignore the frame. */
if ( ( ucRcvAddress == ucMBAddress ) || ( ucRcvAddress == MB_ADDRESS_BROADCAST ) ) {
( void )xMBPortEventPost( EV_EXECUTE );
}
}
break;
case EV_EXECUTE:
ucFunctionCode = ucMBFrame[MB_PDU_FUNC_OFF];
eException = MB_EX_ILLEGAL_FUNCTION;
for ( i = 0; i < MB_FUNC_HANDLERS_MAX; i++ ) {
/* No more function handlers registered. Abort. */
if ( xFuncHandlers[i].ucFunctionCode == 0 ) {
break;
} else if ( xFuncHandlers[i].ucFunctionCode == ucFunctionCode ) {
eException = xFuncHandlers[i].pxHandler( ucMBFrame, &usLength );
break;
}
}
/* If the request was not sent to the broadcast address we
* return a reply. */
if ( ucRcvAddress != MB_ADDRESS_BROADCAST ) {
if ( eException != MB_EX_NONE ) {
/* An exception occured. Build an error frame. */
usLength = 0;
ucMBFrame[usLength++] = ( UCHAR )( ucFunctionCode | MB_FUNC_ERROR );
ucMBFrame[usLength++] = eException;
}
eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength );
}
break;
case EV_FRAME_SENT:
break;
}
}
return MB_ENOERR;
}
socket_cliente[host]=accept(socket_servidor,(struct sockaddr *)&cliente[host],&clilong);
if(socket_cliente[host]<0){
printf("Error aceptando el trafico con el host %s\n",
inet_ntoa(cliente[host].sin_addr));
close(socket_cliente[host]);
close(socket_servidor);
return 1;
}
else
printf("Conectado con el host %s\n",inet_ntoa(cliente[host].sin_addr));
host++;
FD_ZERO(&desc);
FD_SET(socket_servidor,&desc);
for(c=0;c<host;c++)
FD_SET(socket_cliente[c],&desc);