473,326 Members | 2,815 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

protocol development in C language

hi,


i need to develop the protocol for the communication between the two devices which have inbuilt software ,called as event handlers.

i need to activate those event handlers in the first device, by writing the code in C language,the first device is connected at the serial port of the pc.first device can able to send signals to the second device over the powerline.

overall task is how to send a message format from pc to a device connected at the serial port.the message is understandable by the device by means of the inbuilt software of the device.message contains some hex data(8 bytes or 24 bytes of data contains the first device,second device addresses and commands to perform).can u help me by giving some tips.
Jan 28 '07 #1
3 4849
horace1
1,510 Expert 1GB
sounds an interesting project - what operating system/compiler are you using?

as you say you need a protocol to communicate between the two devices. I find the simplest way is to have a header file which contains a typedef which specifies the commands which is included by all the programs on the different devices (assuming they all use C/C++).
e.g. this is one I use to communicats between three seperate programs Matlab (using MEX) via TCP/IP to/from C++ on a host PC which communicates with a SBC6711 DSP target board via USB.
Expand|Select|Wrap|Line Numbers
  1. /*!
  2.     \file commands.h 
  3.     \brief  define commands for MATLAB /PC / DSP communication 
  4.     */
  5. /*! \mainpage define commands for MATLAB /PC / DSP communication 
  6. */
  7.  
  8. #ifndef _Commands_h_
  9. #define _Commands_h_
  10.  
  11. typedef enum {CONNECT=1,                        /**< open connectionfrom Matlab to DSP */
  12.               CLOSECONNECTION,                  /**< Close connection */
  13.               DEFAULTS,                         /**< set defaut parameters for acquisition */
  14.               FREQUENCIES,                      /**< send frequency data from Matlab to DSP */
  15.               ELECTRODES,                       /**< send electrode data from Matlab to DSP */
  16.               STARTACQUISITION,                 /**< tell DSP to start data acquisition */
  17.               GETRESULT,                        /**< return acquisition results from DSP to Matlab */
  18.               SIGNAL,                           /**< set test signal frequency from Matlab */
  19.               PRINTF,                           /**< printf data from DSP to PC to be displayed on PC screen */
  20.               DIO_READ,                         /**<  DigitalI/O > Read DIO port  */
  21.               DIO_WRITE,                        /**<  DigitalI/O > Write DIO port  */
  22.               DIO_SET_BIT,                      /**<  DigitalI/O > Set a DIO bit */
  23.               DIO_RESET_BIT,                    /**<  igitalI/O > Reset a DIO bit */
  24.               DIO_PULSE_BIT,                    /**<  DigitalI/O > Pulse a DIO bit */
  25.               DIO_COUNTER,                      /**<  DigitalI/O > Counter counter */
  26.               DIO_HANDSHAKE,                    /**<  DigitalI/O > Handshake test */
  27.               DIO_WRITECHAR,                    /**<  DigitalI/O > Writeint test */
  28.               RESULTS,                          /**<  Results data structure PC to/from DSP */
  29.               USER_TEST,                        /**<  Tests > User function */
  30.               VERSION=100                       /**< version of this software */
  31. } COMMANDS;
  32.  
  33. #endif
  34.  
the host PC can send a command
Expand|Select|Wrap|Line Numbers
  1.  transmit(STARTACQUISITION);
  2.  
the DSP uses a switch() statement to determine which command has been received, e.g.
Expand|Select|Wrap|Line Numbers
  1.         switch (cmd)
  2.         {
  3.            case FREQUENCIES:             // frequency data received
  4.             {
  5.             //  check maximum size of array and copy values to frequencyData structure
  6.                .....   
  7.             break;
  8.             }
  9.         case ELECTRODES:                // electrode data received
  10.             {
  11.                 .....    
  12.             break;
  13.             }
  14.         case STARTACQUISITION:
  15.             {
  16.                 .....   
  17. etc 
  18.  
hope this gives you some ideas!
Jan 28 '07 #2
hi,
i am using the windows os and turbo c. compiler
Jan 30 '07 #3
horace1
1,510 Expert 1GB
hi,
i am using the windows os and turbo c. compiler
this link contains C code for driving the serial ports under Turbo C V2 or V3
http://www.geocities.com/horacespide..._IO/TurboC_V3/

change the name of rs_lib.h.txt to rs_lib.h
Jan 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

34
by: jblazi | last post by:
Let us assume I have a list like and would like to transoform it into the string '{1,2},{7,8},{12,13}' Which is the simplest way of achiebing this? (The list is in fact much longer and...
14
by: DaveC | last post by:
I know this is the wrong group but I need a little pointing in a direction please. I need to write an implementation of a yet to be published protocol. It is transported over the internet via...
0
by: brewhaha | last post by:
Greetings from the fifty-second parallel, My Sirs and Madams of Edmonton Public Library, the World Wide Web Consortium situated primarily at Michigan I.T., and Edmonton Community Network. To fail...
0
by: shoorik | last post by:
Folks, SiteID is an exciting new protocol that I've been planning and designing during the past couple of months. It's currently in early release, but I've been hoping to make somewhat of a...
12
by: Laszlo Zsolt Nagy | last post by:
Hello, I would like to develop a new network protocol, where the server and the clients are Python programs. I think to be effective, I need to use TCP_NODELAY, and manually buffered transfers....
0
by: admin | last post by:
TCP/IP UDP Protocol Development Library and Resources Free VC++ 6.0 (ws2_32.lib) Winsock 2 TCP/IP Library complete with project source implements TCP/IP Header construction, Checksum...
3
by: yawnmoth | last post by:
I've seen a few webpages that use the javascript pseudo-protocol with event handlers. eg. <input onkeyup="javascript: ..." /> Correct me if I'm wrong, but isn't onkeyup always supposed to be...
2
by: luca.moreschi | last post by:
Dear all, I'd like to learn more about Dicom communication protocol. Taking a look in internet seems that I need the document "PS 3.9-1993 Point to point communication" from Nema or something...
9
by: Nick | last post by:
Hi there, I would like to perform something like the following from my vb.net web service, being invoked via HTTP Post Call HttpContext.Current.Response.Redirect("myprotocol://myurl") ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.