Writing to sockets with Citect

zankorel

Member
Join Date
Dec 2008
Location
Hunter Valley
Posts
173
Has anyone found a way to write/read to a socket (ie IPaddress:port) using Citect? Without purchasing their driver SDK...

I am looking at writing an external app that will accept parameters, but it would be so much better if Citect could handle it natively!
 
Last edited:
Thats not that hard to do.

You can use the ComOpen() function. I know it sounds as a com port function but if you define a ehternet socket it works just as wel. the only problem is that you can only connect to a listening socket, you can't create a listening socket and accept connections.

Regards,

Marsu
 
Have you done this yourself? I dont understand how it would work.

Where would you specify the IP address and port number? The IP address at least is normally a field that the IO device driver interprets, Citect doesn't know what it means.

Can you give a bit more information about how you set it up to work?
 
I have done this several times.

You only need to specify a communication board: Type TCPIP
and a communication port: in the Special Opt of the port you can specify the ip address and the port. example: -I10.134.8.34 -P7165 -T.

Then with the comopen function you specify the port name, done.

Hope this helps,

Marsi
 
I have done this several times.

You only need to specify a communication board: Type TCPIP
and a communication port: in the Special Opt of the port you can specify the ip address and the port. example: -I10.134.8.34 -P7165 -T.

Then with the comopen function you specify the port name, done.

Hope this helps,

Marsi

Thats awesome! thanks very much for the tip. I will give it a go next week
 
Hey guys,

I'm new to this forum and if its ok would like to butt into this thread because it is exactly what i am looking for, rather than creating a new one altogether.

Basically I am trying to do the same thing. Instead of using the DDK i simply want to read in ASCI data from a remote TCP port using cicode.

Currently I have the board and port set up as follows..

Board: Board TCPIP Type TCPIP, Address 0
Port: Name X Number 1 Board TCPIP Special Opt -I10.200.61.1 -P50030 -T

Now i have checked using a command line that i can connect to that port with that IP address and it definately works, however when i use the ComOpen command I get a return value of -1.

I have tried both 0 and 1 as Mode on the ComOpen(Port, Mode) section but still get the same return value.

Can you suggest a reason why this isn't working? Is it to do with the fact that the device im communicating to needs to return a certain string value back to citect? or is it because i can only talk to a listening port not a slave port?
 
to be honest im not sure...

I am just doing a test at the moment.

The way i have it set up is, I have a cicode function linked on the main page. In that function i just call a cicode subroutine.. this intern calls the ComOpen function as it executes.

I have a prompt in there that tells me on the main page that the com port has failed.
 
to be honest im not sure...

I am just doing a test at the moment.

The way i have it set up is, I have a cicode function linked on the main page. In that function i just call a cicode subroutine.. this intern calls the ComOpen function as it executes.

I have a prompt in there that tells me on the main page that the com port has failed.

Well, all your config looks fine, so either you have put incorrect parameters for the device (ie IP address and port) or you are not executing the code on an IO server, or not the IO Server process if you are running on multi-process.

The other possibility is that you are trying to open the same port multiple times before closing it.
 
Still not functioning.

Well I have double checked all the parameters and made sure all the networking is fine.

The only thing that I haven't been able to do is confirm that I am running these Cicode functions from an IO server process.

I am using their sample code from ComOpen() function.
Is there somewhere in there i should be inserting a [IOServer] or [IOServer.Cluster] type suffix? if so where would it go?

All i have really is a cicode file called main.ci with a number of functions in it. One is called StartSerial and it takes a (String DR). I then have a cicode function running on my main page which does nothing else except StartSerial(DR), where DR is the name of the port.

I am a bit confused. Any help would be fantastic.
 
Hey Craig,

You should really be able to get this to work.

Some things you could try/things that come to mind.

- Telnet ipaddress port is working from the scada machine to the destination?
- Did you run the computer setup on the scada machine
- Do not run in multi process (then you are a ioserver if you are not a client application)
- What version of citect are you running
- Use tcpipview and/or wireshark to monitor what is happening on TCP level
- Use [TCPIP]debug parameter to see what citect is doing on TCP level
- are both sides using UDP or TCP?
- any messages on the hardware page or in the kernel?

Hope this can get you started.

Regards,

Marsi
 
Hey Craig,

Now that I saw your code on the user list the problem is easaly spotted. you have to define a port in the project editor and use the name of the port in the ComOpen function.

Its always easy to post some code as well.

Marsi
 

Similar Topics

Hi, I'm having an issue in crimson 3.0 when I create a programme using a case statement referencing a fault word that each bit needs to change the...
Replies
4
Views
194
Hello all, I'm currently working on a servo motor linear positioning system (ball screw). I'm all set up regarding communication between my HMI...
Replies
1
Views
90
Hello All: I have a Windows 10 PC running a FTView ME Station 10.00. I have a .mer file version 6.00. It has been running well on it for a long...
Replies
1
Views
166
My R55 Ingersollrand is tripping on motor overload and im falling to see the trip history it is writing Acquarring texts
Replies
0
Views
132
Hi. Not the fist time I'm saying this but just to give a background. 95% of my PLC programming has used Schneider over the last 10 years on...
Replies
66
Views
4,952
Back
Top Bottom