Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement test semaphore functions #4

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ANSIC.lby
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio FileVersion="4.9"?>
<Library Version="1.03.5" SubType="ANSIC" xmlns="http://br-automation.co.at/AS/Library">
<Library Version="1.04.1" SubType="ANSIC" xmlns="http://br-automation.co.at/AS/Library">
<Files>
<File>LICENSE.txt</File>
<File>VersionHistory.txt</File>
Expand Down
1 change: 1 addition & 0 deletions OMJSON.fun
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,4 @@ FUNCTION jsonEscape : UDINT (*Escape JSON string*)
reentry : UDINT;
END_VAR
END_FUNCTION

15 changes: 13 additions & 2 deletions jsonWebSocketServer.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void jsonWebSocketServer(struct jsonWebSocketServer* t)

// TODO: Clear buffers on init


// Set up tcpServer
t->internal.tcpServer.IN.CFG.Mode = TCPCOMM_MODE_SERVER;
strcpy(t->internal.tcpServer.IN.CFG.LocalIPAddress, t->ServerIP);
Expand All @@ -108,7 +109,6 @@ void jsonWebSocketServer(struct jsonWebSocketServer* t)

} // if(!initialized)


// Check license
//---------------

Expand All @@ -121,8 +121,10 @@ void jsonWebSocketServer(struct jsonWebSocketServer* t)

// Manage TCP server
//-------------------


lockComms( 0 );
TCPManageConnection(&t->internal.tcpServer);
unlockComms( 0 );

if (t->internal.tcpServer.OUT.NewConnectionAvailable) {

Expand Down Expand Up @@ -183,7 +185,11 @@ void jsonWebSocketServer(struct jsonWebSocketServer* t)

t->internal.client[index].debug.oldDataReceived = t->internal.client[index].tcpStream.OUT.DataReceived;

lockComms( 0 );

TCPStreamReceive(&t->internal.client[index].tcpStream);

unlockComms( 0 );

if (t->internal.client[index].debug.oldDataReceived && t->internal.client[index].tcpStream.OUT.DataReceived) {
// Break here to figure out what happens
Expand Down Expand Up @@ -531,7 +537,9 @@ void jsonWebSocketServer(struct jsonWebSocketServer* t)

} // NewDataAvailable && !Sending

lockComms( 0 );
TCPStreamSend(&t->internal.client[index].tcpStream);
unlockComms( 0 );

t->internal.client[index].tcpStream.IN.CMD.Send = 0;

Expand All @@ -556,3 +564,6 @@ void jsonWebSocketServer(struct jsonWebSocketServer* t)
} // End For Clients

} // End Fn