AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

I need CS to turn on an LED.  What is the best way?
 
 

Hi,

I’m very new to CS.  I just downloaded it and built a very simple dog-bot that acts like a talking dog.  I’m impressed that I can do that just hours after downloading.

I have a large project in mind but first I want to do a simple “Hello World” example as follows:  User types “turn on the LED” and the LED goes on.  Assume I have a function in C called “turnOnLED()”

What is the best way to connect CS to this C function?

Reading the documentation it seems that I call tcpopen() with a parameters like “post, http::localhost/LED?state=1”  Then I write a server process that waits for POSTs and acts on them.

I think I might get the above to work but there is a LOT of wasted CPU cycles.  Is tcpopen the most efficient method?  I’ve only been reading for a couple hours so there is likely a lot I don’t know yet.

Thanks.

 

 

 
  [ # 1 ]

It is possible to extend CS with your own functions, so you could have the script line ^switchLED(on) and that actually runs your C function.

In the documentation look for private functions. Can’t remember exactly where it is, but it is pretty simple to do.

 

 
  [ # 2 ]

if your cs engine is on the same machine as the code to turn on the light, you can use popen or system to talk to the local system. But efficiency is not really an important criterion I would think

 

 
  [ # 3 ]

You can make http calls to JSON services.  I think it’s simpler than use tcp connections.

 

 
  login or register to react