Hello,
You suggested me options to connect my GUI with Rabbit.
I am gonna communicate over a network, wired or wireless and want to handle messages with
TCP/MODBUS.
I went through all the libraries and sample program for tcpip.
What I understood till now is that I have to write a Server application for my rabbit
processor and
TCP client application can update the MS Access database with the help of TCP listner
software written in VB and running on Host PC.
I never worked on such application before.
I read about server/client process and got the basic idea.
Application need to create the socket first.
Attach the socket to an IP address and port number.
Server can then get into a listen state and listen for incoming connections.
I am trying to make Rabbit Smartstar processor as a server.
And wanna transfer the Analog or digital data to the client computer.
Also I wanna upload the changes on the server processor through the client computer.
I have written a small application.
Doubtful how to test that, as when I run it. I can see the ACT,LNK,PWR lights blinking.
but my program is not showing any printf statements.
Please excuse if I sound wrong at some point.
Please suggest me what particular sample programs and libraries I should look at for this
application.
All suggestions are welcome.
Thanks,
MJ
--- In r...@yahoogroups.com, "John"
wrote:
>
> --- In r...@yahoogroups.com, "josan_manu1" wrote:
> >
> > Hello,
> >
> > Please, can some one tell me how to interface GUI with rabbit processor code. I am
making GUI in VB and using rabbit smartstar toolkit.
> >
> > I want data from the analog and digital cards through Ethernet.
> >
> > Also wanna reset relays from GUI.
> >
> > If some one has worked with such application please guide me.
> >
> >
> >
> > Thanks,
> > MJ
> >
> You have a few options, depending on system architecture. How are you going to connect
your GUI (PC?) to the rabbit?
>
> 1: If it's directly, via a serial connection of some sort, then you'll be writing your
message handlers for the serial code.
>
> 2: If you're goig to be communicating over a network, wired or wireless, then another
option is to handle mesages over TCP or UDP.
>
> What you write your GUI code in is a matter of personal preference, and what's available
for the platform you have in mind.
>
> 3: Another network option, would be to use a web interface hosted directly on the
rabbit, using rabbitweb, or similar. Whether or not this is appropriate depends on what
you're trying to implement in the GUI, and whether or not you consider a web interface to
be a true GIU at all!
>
> I have a lot of experience with options 1 and 2, but not so much with number 3.
>
> I hope that helps, but we'll really need a bit more information about what you're trying
to achieve to be more specific.
>
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )Hello All,
I have written this code.
I got all ideas after reading Rabbit documentation.
I found that at processor end I need to make client application and my host will be
server.
#define TCPCONFIG 1
#define FILE "/"
#define PORT 7
#memmap xmem
#use "dcrtcp.lib"
//#define USE_ETHERNET
main() {
int status;
tcp_Socket s;
char buffer[2048];
longword ip;
sock_init();
//ip=resolve(WEBSITE);
tcp_open(&s,0,ip,PORT,NULL);
printf("Socket Open Successful");
When program runs it print this meassge, but not the one highlighted below.
This means that the socket establishment is not succesful. Please tell me what I am doing
incorrect.
sock_wait_established(&s,0,NULL,&status);
printf("Socket Established");
if (!tcp_open(&s,0,ip,PORT,NULL))
printf("Failed to open\n");
else while(!sock_established(&s)) {
if (!tcp_tick(&s)) {
printf("Failed to establish\n");
break;
}
}
if (sock_established(&s)) {
printf("Established OK!\n");
// do whatever needs to be done...
}
printf("connection established");
sock_mode(&s,TCP_MODE_ASCII);
sprintf(buffer,"GET %s\r\n",FILE);
sock_puts(&s,buffer);
while(tcp_tick(&s)) {
sock_wait_input(&s,0,NULL,&status);
if(sock_gets(&s,buffer,2048))
printf("%s\n",buffer);
}
return 0;
//An Introduction to TCP/IP rabbit.com 31
sock_err:
switch(status) {
case 1: /* foreign host closed */
printf("User closed session\n");
break;
case -1: /* time-out */
printf("\nConnection timed out\n");
break;
}
}
MJ
________________________________
From: mandeep
To: r...@yahoogroups.com
Sent: Tue, 20 October, 2009 9:31:25 AM
Subject: [rabbit-semi] Re: Need detail guidance
Hello,
You suggested me options to connect my GUI with Rabbit.
I am gonna communicate over a network, wired or wireless and want to handle messages with
TCP/MODBUS.
I went through all the libraries and sample program for tcpip.
What I understood till now is that I have to write a Server application for my rabbit
processor and
TCP client application can update the MS Access database with the help of TCP listner
software written in VB and running on Host PC.
I never worked on such application before.
I read about server/client process and got the basic idea.
Application need to create the socket first.
Attach the socket to an IP address and port number.
Server can then get into a listen state and listen for incoming connections.
I am trying to make Rabbit Smartstar processor as a server.
And wanna transfer the Analog or digital data to the client computer.
Also I wanna upload the changes on the server processor through the client computer.
I have written a small application.
Doubtful how to test that, as when I run it. I can see the ACT,LNK,PWR lights blinking.
but my program is not showing any printf statements.
Please excuse if I sound wrong at some point.
Please suggest me what particular sample programs and libraries I should look at for this
application.
All suggestions are welcome.
Thanks,
MJ
--- In rabbit-semi@ yahoogroups. com, "John" wrote:
>
> --- In rabbit-semi@ yahoogroups. com, "josan_manu1" wrote:
> >
> > Hello,
> >
> > Please, can some one tell me how to interface GUI with rabbit processor code. I am
making GUI in VB and using rabbit smartstar toolkit.
> >
> > I want data from the analog and digital cards through Ethernet.
> >
> > Also wanna reset relays from GUI.
> >
> > If some one has worked with such application please guide me.
> >
> >
> >
> > Thanks,
> > MJ
> >
> You have a few options, depending on system architecture. How are you going to connect
your GUI (PC?) to the rabbit?
>
> 1: If it's directly, via a serial connection of some sort, then you'll be writing your
message handlers for the serial code.
>
> 2: If you're goig to be communicating over a network, wired or wireless, then another
option is to handle mesages over TCP or UDP.
>
> What you write your GUI code in is a matter of personal preference, and what's available
for the platform you have in mind.
>
> 3: Another network option, would be to use a web interface hosted directly on the
rabbit, using rabbitweb, or similar. Whether or not this is appropriate depends on what
you're trying to implement in the GUI, and whether or not you consider a web interface to
be a true GIU at all!
>
> I have a lot of experience with options 1 and 2, but not so much with number 3.
>
> I hope that helps, but we'll really need a bit more information about what you're trying
to achieve to be more specific.
>
Yahoo! India has a new look. Take a sneak peek http://in.yahoo.com/trynew

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )Number 1, the call to tcp_open() does not open the connection, it merely starts the
process.
I don’t see in your code what the IP address is as that line is commented out. Try using
a dotted notation first before trying to do a resolve. E.g.
ip = inet_addr(“192.168.1.1”); // Get IP as a word
TCP/IP on the Rabbit is not too difficult but it does require a fair bit of code to get it
working reliably. I prefer to use a state machine for connecting to the network. Here is a
simplified version of what I have. I repeatedly call this code and between calls, call
TCP_TICK() to make sure the TCP stuff gets done in the background.
Note that I am using UCOS with this code but it should work without this. This is not
complete and is just for example use only to show a simpler way to make a connection
without hanging up your code. VsState is a structure holding information about what is
being sent and timeouts etc.
int SocketHandler(VsState* pVsState)
{
tcp_Socket* socket;
longword ServerIP;
uint ServerPort;
char err;
int len;
socket = pVsState->socket;
switch(pVsState->State)
{
case VS_INIT:
//
// Passive open on the socket port
//
ServerIP = inet_addr(StrServerIP); // Get IP as a word
ServerPort = atoi(StrServerPort);
if (tcp_open(socket, 0, ServerIP, ServerPort, NULL) != 0)
{
pVsState->State=VS_OPENING;
pVsState->OpenTimeout = MS_TIMER + OPEN_TIMEOUT; // x seconds to open
printf("Opening socket\n");
Server.Status = SERVER_STATUS_CONNECTING;
}
else
{
Server.Status = SERVER_STATUS_CONNECTFAILED;
pVsState->Attempts++;
if(pVsState->Attempts > MAX_ATTEMPTS)
{
pVsState->State=VS_INIT; // Go back to waiting
Server.Status = SERVER_STATUS_IDLE;
TCPIPErrorCount++; // Increment error count
return TCP_CONN_ERROR;
}
}
break;
case VS_OPENING:
//
// Wait for a connection to complete
//
if(sock_established(socket)) // || sock_bytesready(socket) >= 0)
{
pVsState->State = VS_SEND;
sock_mode(socket, TCP_MODE_BINARY);
printf("TCP/IP Connected\n");
TCPIPErrorCount = 0; // Reset the
error counter
Server.Status = SERVER_STATUS_CONNECTED;
}
else
{
if(MS_TIMER > pVsState->OpenTimeout)
{
//
// Failed to open
//
printf("TCP/IP Failed Open\n");
Server.Status =
SERVER_STATUS_CONNECTFAILED;
sock_abort(socket);
sock_close(socket);
pVsState->State=VS_INIT; // Go back to waiting
pVsState->Attempts++;
if(pVsState->Attempts > MAX_ATTEMPTS)
{
pVsState->State=VS_INIT; // Go back to waiting
Server.Status =
SERVER_STATUS_IDLE;
TCPIPErrorCount++; // Increment
error count
return TCP_CONN_ERROR;
}
OSTimeDlySec(2);
}
}
break;
case VS_SEND:
if(sock_writable(socket))
{
// Now we can send the data
pVsState->sent = sock_write(socket, pVsState->packet,
pVsState->send );
if ( pVsState->sent == -1 )
{
TCPIPErrorCount++; // Increment
error count
return TCP_SEND_ERROR;
}
pVsState->State = VS_RECV;
pVsState->OpenTimeout = MS_TIMER + 5000L; // Wait 5
seconds for data
}
else
{
OSTimeDly(8); // Wait 0.25 seconds
before trying again
}
break;
case VS_RECV:
len = sock_bytesready(socket);
if(len > 0)
{
pVsState->rcvd = sock_read(socket, pVsState->packet, len
);
if(pVsState->rcvd == -1)
{
sock_close(socket);
pVsState->State = VS_INIT;
return TCP_RECV_ERROR;
}
pVsState->State = VS_CLOSE;
}
else if (MS_TIMER > pVsState->OpenTimeout)// if X msec and
still waiting
{
sock_close(socket);
pVsState->State = VS_INIT;
return TCP_CONN_ERROR;
}
break;
case VS_WAITCLOSE:
if(! sock_established(socket))
{
//
// Socket closed so go back to init
//
pVsState->State = VS_INIT;
return TCP_OK;
}
return TCP_BUSY; // return the number of bytes received
case VS_CLOSE:
sock_close(socket);
printf("TCP/IP closed\n\n");
pVsState->State = VS_WAITCLOSE;
Server.Status = SERVER_STATUS_IDLE;
TCPIPErrorCount = 0; // Reset error count
return TCP_BUSY;
break;
default:
//
// how did we get here? programming error?
//
pVsState->State=VS_INIT;
break;
}
return TCP_BUSY;
Dave...
---
Very funny Scotty, now beam down my clothes!!!
---
http://www.embeddedcomputer.co.uk
---
From: r...@yahoogroups.com [mailto:r...@yahoogroups.com] On Behalf Of mandeep kaur
Sent: 21 October 2009 12:33
To: r...@yahoogroups.com
Subject: {Disarmed} Re: [rabbit-semi] Re: Need detail guidance
Hello All,
I have written this code.
I got all ideas after reading Rabbit documentation.
I found that at processor end I need to make client application and my host will be
server.
#define TCPCONFIG 1
#define FILE "/"
#define PORT 7
#memmap xmem
#use "dcrtcp.lib"
//#define USE_ETHERNET
main() {
int status;
tcp_Socket s;
char buffer[2048];
longword ip;
sock_init();
//ip=resolve(WEBSITE);
tcp_open(&s,0,ip,PORT,NULL);
printf("Socket Open Successful");
When program runs it print this meassge, but not the one highlighted below.
This means that the socket establishment is not succesful. Please tell me what I am doing
incorrect.
sock_wait_established(&s,0,NULL,&status);
printf("Socket Established");
if (!tcp_open(&s,0,ip,PORT,NULL))
printf("Failed to open\n");
else while(!sock_established(&s)) {
if (!tcp_tick(&s)) {
printf("Failed to establish\n");
break;
}
}
if (sock_established(&s)) {
printf("Established OK!\n");
// do whatever needs to be done...
}
printf("connection established");
sock_mode(&s,TCP_MODE_ASCII);
sprintf(buffer,"GET %s\r\n",FILE);
sock_puts(&s,buffer);
while(tcp_tick(&s)) {
sock_wait_input(&s,0,NULL,&status);
if(sock_gets(&s,buffer,2048))
printf("%s\n",buffer);
}
return 0;
//An Introduction to TCP/IP rabbit.com 31
sock_err:
switch(status) {
case 1: /* foreign host closed */
printf("User closed session\n");
break;
case -1: /* time-out */
printf("\nConnection timed out\n");
break;
}
}
MJ

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )