Problem of connecting C program with lua progam

Beginner's forum - issues with the installation and startup of the iCat Research Platform

Moderators: iCat support, Support

Problem of connecting C program with lua progam

Postby Oratile » Fri Aug 31, 2007 7:09 pm

Hi there.

I have a small problem here that i am unable to fugure it out.
I am running Atom Dialogue SDK in my machine that convert speech to text. I have created a server using C programming and the converted text is send in to the server. Then i have created lua socket to communicate with the server and get the text into lua program. The socket seem to work but text from the server is not reflected in lua program. Does anyone knows why?

I have attached server.c, server.exe (C program that create the server) CommSocket.lua and CommSocket.xml for consideration

For more information, i am running server program using cygwin shell.
Attachments
server.c
(3.87 KiB) Downloaded 789 times
commSocket.lua
(967 Bytes) Downloaded 835 times
commSocketConfig.xml
(190 Bytes) Downloaded 816 times
Oratile
Oratile
 
Posts: 20
Joined: Thu Mar 01, 2007 5:51 pm
Location: Nelson Mandela Metropolitan University, South Africa

Postby Taapie » Mon Sep 03, 2007 8:16 am

Hi Oratile,

I had a look at your lua script and noticed that you are trying to do two things at the same time.

1) wait for data on the socket
2) wait for data on a DML port

You use DoAction to do 1) and use a callback function on the port to do 2). The problem is that while you are doing 1) using the tcp:receive function, 2) can not occur. This has to do with the fact that the DML loop is the main loop, which calls the DoAction function. While it is running the DoAction function it can not do anything else (including receiving messages and calling port callback functions).

As you do not share data or actions between results in 1) and 2) it would be a better solution to separate the two actions into two scripts and run two scripting modules. One waiting for data on the socket and the other waiting for data on the port.

Try it out and see if it works.

Greetings,

Dennis
Taapie
 
Posts: 185
Joined: Mon Apr 04, 2005 12:52 pm
Location: Eindhoven, The Netherlands

it works

Postby Oratile » Mon Sep 03, 2007 8:15 pm

Thanks, Denis

I can now see text from the server into lua program.
I am sorry to ask this question related to c programming: It accept one connection. I want one connection from Atom dialogue that sends text into the server, then another connection from lua program that takes text from server into lua program.
Currently, when i test connection between Atom SDK, it works and able to get text (text converted from speech) into the server. Also when i switch off Atom SDK and connect from lua program the connection works. The problem is when i run two systems: OPPR (lua side) and Atom and both trying to connect to the server. Atom sending and OPPR receiving. I tried to use master sockets to allow more than one connection but the situation still is the same.

I have attached this server.c file that i am using as a server for further information. does anyone know what i should change to get these two system to communicate via sockets. I will appreciate any suggetion Please!
Attachments
commSocket.lua
(1.29 KiB) Downloaded 609 times
commSocket.lua
(1.29 KiB) Downloaded 698 times
server.c
(7.56 KiB) Downloaded 663 times
Oratile
Oratile
 
Posts: 20
Joined: Thu Mar 01, 2007 5:51 pm
Location: Nelson Mandela Metropolitan University, South Africa

Postby Taapie » Thu Sep 06, 2007 9:55 am

Hi Oratile,

I looked at your server.c file and it looks confusing, what i can see are the following:

- you use 'while (1)' to run the connection loop. I am guessing you see two connections, but nothing else happening. This is because the loop will never end (so no read or write actions).

- you only have one socket variable called new_socket. This means that you only remember the second connection and just loose the first socket identifier. The second connection can be either Atom or OPPR (lua)

- You call 'strlen(buffer1) > 0' on an uninitialized buffer in your 'receive/send' code, this will most probably crash your software when build in release mode.

- You only use WriteLines and no ReadLines, after the 'while(1)' loop. This means that nothing gets received.

You will have to fix these things: you can either use two socket identifiers, but you will have to find out which belongs to Atom and which to OPPR (lua). Or you could just drop the master socket and use two different socket ports, which makes it easier to know where Atom is connected to. Next make sure you continue after getting two connections and wait for a read before doing a write. Also make sure your buffers have some initial value, like 'buffer1[0] = 0;'.

Hope this helps.

Greetings,

Dennis
Taapie
 
Posts: 185
Joined: Mon Apr 04, 2005 12:52 pm
Location: Eindhoven, The Netherlands

C server worked

Postby Oratile » Mon Sep 17, 2007 9:10 am

Thank you very much.
I used two separate socket ports for each subsystems (OPPR and Atom) and it worked.
Oratile
Oratile
 
Posts: 20
Joined: Thu Mar 01, 2007 5:51 pm
Location: Nelson Mandela Metropolitan University, South Africa


Return to Beginner

Who is online

Users browsing this forum: No registered users and 1 guest

cron