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