forked from thiagoralves/OpenPLC_v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added raw TCP/IP on matIEC text libs
- Loading branch information
1 parent
8b3c164
commit 0efb47c
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
(* | ||
* This file is part of OpenPLC - an open source Programmable | ||
* Logic Controller compliant with IEC 61131-3 | ||
* | ||
* Copyright (C) 2022 Thiago Alves | ||
* | ||
* See COPYING and COPYING.LESSER files for copyright details. | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
* USA | ||
* | ||
* This code is made available on the understanding that it will not be | ||
* used in safety-critical situations without a full and competent review. | ||
*) | ||
|
||
|
||
|
||
(* | ||
* An IEC 61131-3 compiler. | ||
* | ||
* Based on the | ||
* FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10) | ||
* | ||
*) | ||
|
||
|
||
(* | ||
* This is a dummy implementation of those block since | ||
* its code is actually written in C, not ST | ||
*) | ||
|
||
(* | ||
* TCP_CONNECT | ||
* ------------- | ||
*) | ||
FUNCTION_BLOCK TCP_CONNECT | ||
VAR_INPUT | ||
CONNECT : BOOL; | ||
IP_ADDRESS : STRING; | ||
PORT : INT; | ||
END_VAR | ||
VAR_OUTPUT | ||
SOCKET_ID : INT; | ||
END_VAR | ||
SOCKET_ID := 0; | ||
END_FUNCTION_BLOCK | ||
|
||
(* | ||
* TCP_SEND | ||
* ------------- | ||
*) | ||
FUNCTION_BLOCK TCP_SEND | ||
VAR_INPUT | ||
SEND : BOOL; | ||
SOCKET_ID : INT; | ||
MSG : STRING; | ||
END_VAR | ||
VAR_OUTPUT | ||
BYTES_SENT : INT; | ||
END_VAR | ||
BYTES_SENT := 0; | ||
END_FUNCTION_BLOCK | ||
|
||
(* | ||
* TCP_RECEIVE | ||
* ------------- | ||
*) | ||
FUNCTION_BLOCK TCP_RECEIVE | ||
VAR_INPUT | ||
RECEIVE : BOOL; | ||
SOCKET_ID : INT; | ||
END_VAR | ||
VAR_OUTPUT | ||
BYTES_RECEIVED : INT; | ||
MSG : STRING; | ||
END_VAR | ||
BYTES_RECEIVED := 0; | ||
END_FUNCTION_BLOCK | ||
|
||
(* | ||
* TCP_CLOSE | ||
* ------------- | ||
*) | ||
FUNCTION_BLOCK TCP_CLOSE | ||
VAR_INPUT | ||
CLOSE : BOOL; | ||
SOCKET_ID : INT; | ||
END_VAR | ||
VAR_OUTPUT | ||
SUCCESS : INT; | ||
END_VAR | ||
SUCCESS := 0; | ||
END_FUNCTION_BLOCK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters