Protocole MB
port/portevent.cpp@1:1ff8c07b8c2e, 2021-04-02 (annotated)
- Committer:
- mohamedwajdi
- Date:
- Fri Apr 02 10:04:07 2021 +0000
- Revision:
- 1:1ff8c07b8c2e
- Parent:
- 0:aefcdfe9ca2f
TP3 RBT 2GII ENETCOM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
stanley1228 | 0:aefcdfe9ca2f | 1 | /* |
stanley1228 | 0:aefcdfe9ca2f | 2 | * FreeModbus Libary: BARE Port |
stanley1228 | 0:aefcdfe9ca2f | 3 | * Copyright (C) 2006 Christian Walter <wolti@sil.at> |
stanley1228 | 0:aefcdfe9ca2f | 4 | * |
stanley1228 | 0:aefcdfe9ca2f | 5 | * This library is free software; you can redistribute it and/or |
stanley1228 | 0:aefcdfe9ca2f | 6 | * modify it under the terms of the GNU Lesser General Public |
stanley1228 | 0:aefcdfe9ca2f | 7 | * License as published by the Free Software Foundation; either |
stanley1228 | 0:aefcdfe9ca2f | 8 | * version 2.1 of the License, or (at your option) any later version. |
stanley1228 | 0:aefcdfe9ca2f | 9 | * |
stanley1228 | 0:aefcdfe9ca2f | 10 | * This library is distributed in the hope that it will be useful, |
stanley1228 | 0:aefcdfe9ca2f | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
stanley1228 | 0:aefcdfe9ca2f | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
stanley1228 | 0:aefcdfe9ca2f | 13 | * Lesser General Public License for more details. |
stanley1228 | 0:aefcdfe9ca2f | 14 | * |
stanley1228 | 0:aefcdfe9ca2f | 15 | * You should have received a copy of the GNU Lesser General Public |
stanley1228 | 0:aefcdfe9ca2f | 16 | * License along with this library; if not, write to the Free Software |
stanley1228 | 0:aefcdfe9ca2f | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
stanley1228 | 0:aefcdfe9ca2f | 18 | * |
stanley1228 | 0:aefcdfe9ca2f | 19 | * File: $Id: portevent.c,v 1.1 2006/08/22 21:35:13 wolti Exp $ |
stanley1228 | 0:aefcdfe9ca2f | 20 | */ |
stanley1228 | 0:aefcdfe9ca2f | 21 | |
stanley1228 | 0:aefcdfe9ca2f | 22 | /* ----------------------- Modbus includes ----------------------------------*/ |
stanley1228 | 0:aefcdfe9ca2f | 23 | #include "mb.h" |
stanley1228 | 0:aefcdfe9ca2f | 24 | #include "mbport.h" |
stanley1228 | 0:aefcdfe9ca2f | 25 | |
stanley1228 | 0:aefcdfe9ca2f | 26 | /* ----------------------- Variables ----------------------------------------*/ |
stanley1228 | 0:aefcdfe9ca2f | 27 | static eMBEventType eQueuedEvent; |
stanley1228 | 0:aefcdfe9ca2f | 28 | static BOOL xEventInQueue; |
stanley1228 | 0:aefcdfe9ca2f | 29 | |
stanley1228 | 0:aefcdfe9ca2f | 30 | /* ----------------------- Start implementation -----------------------------*/ |
stanley1228 | 0:aefcdfe9ca2f | 31 | BOOL |
stanley1228 | 0:aefcdfe9ca2f | 32 | xMBPortEventInit( void ) |
stanley1228 | 0:aefcdfe9ca2f | 33 | { |
stanley1228 | 0:aefcdfe9ca2f | 34 | xEventInQueue = FALSE; |
stanley1228 | 0:aefcdfe9ca2f | 35 | return TRUE; |
stanley1228 | 0:aefcdfe9ca2f | 36 | } |
stanley1228 | 0:aefcdfe9ca2f | 37 | |
stanley1228 | 0:aefcdfe9ca2f | 38 | BOOL |
stanley1228 | 0:aefcdfe9ca2f | 39 | xMBPortEventPost( eMBEventType eEvent ) |
stanley1228 | 0:aefcdfe9ca2f | 40 | { |
stanley1228 | 0:aefcdfe9ca2f | 41 | xEventInQueue = TRUE; |
stanley1228 | 0:aefcdfe9ca2f | 42 | eQueuedEvent = eEvent; |
stanley1228 | 0:aefcdfe9ca2f | 43 | return TRUE; |
stanley1228 | 0:aefcdfe9ca2f | 44 | } |
stanley1228 | 0:aefcdfe9ca2f | 45 | |
stanley1228 | 0:aefcdfe9ca2f | 46 | BOOL |
stanley1228 | 0:aefcdfe9ca2f | 47 | xMBPortEventGet( eMBEventType * eEvent ) |
stanley1228 | 0:aefcdfe9ca2f | 48 | { |
stanley1228 | 0:aefcdfe9ca2f | 49 | BOOL xEventHappened = FALSE; |
stanley1228 | 0:aefcdfe9ca2f | 50 | |
stanley1228 | 0:aefcdfe9ca2f | 51 | if( xEventInQueue ) |
stanley1228 | 0:aefcdfe9ca2f | 52 | { |
stanley1228 | 0:aefcdfe9ca2f | 53 | *eEvent = eQueuedEvent; |
stanley1228 | 0:aefcdfe9ca2f | 54 | xEventInQueue = FALSE; |
stanley1228 | 0:aefcdfe9ca2f | 55 | xEventHappened = TRUE; |
stanley1228 | 0:aefcdfe9ca2f | 56 | } |
stanley1228 | 0:aefcdfe9ca2f | 57 | return xEventHappened; |
stanley1228 | 0:aefcdfe9ca2f | 58 | } |