Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
65 | f9daq | 1 | /************************************************************************** |
2 | lecroy_example.c |
||
3 | Version 1.00 |
||
4 | Copyright (C) 2003 Steve D. Sharples |
||
5 | |||
6 | This program is free software; you can redistribute it and/or |
||
7 | modify it under the terms of the GNU General Public License |
||
8 | as published by the Free Software Foundation; either version 2 |
||
9 | of the License, or (at your option) any later version. |
||
10 | |||
11 | This program is distributed in the hope that it will be useful, |
||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
14 | GNU General Public License for more details. |
||
15 | |||
16 | You should have received a copy of the GNU General Public License |
||
17 | along with this program; if not, write to the Free Software |
||
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
19 | |||
20 | The author's email address is steve.sharples@nottingham.ac.uk |
||
21 | |||
22 | *************************************************************************** |
||
23 | |||
24 | Example program that demonstrates communication via TCP/IP with an ethernet- |
||
25 | enabled LeCroy DSO. Based on the main() function of "net_con.cpp" written |
||
26 | by LeCroy. |
||
27 | |||
28 | See "lecroy_tcp.c" and "lecroy_tcp.h" for additional comments and usage |
||
29 | |||
30 | **************************************************************************/ |
||
31 | |||
32 | |||
33 | #include "lecroy_tcp.h" |
||
34 | #include <stdio.h> |
||
35 | #include <string.h> |
||
36 | using namespace std; |
||
37 | |||
38 | #define MAX_ST 512 /* maximum message string. no picked from thin air */ |
||
39 | |||
40 | int main () |
||
41 | { |
||
42 | char ip_address[50]; |
||
43 | int sockfd; |
||
44 | char outbuf[MAX_ST]; |
||
45 | char inbuf[MAX_ST]; |
||
46 | float fvalue; |
||
47 | int ivalue; |
||
48 | |||
49 | |||
50 | /* OUR_SCOPE_IP is #define'd in lecroy_tcp.h, so is MAX_TCP_CONNECT */ |
||
51 | sprintf(ip_address, OUR_SCOPE_IP); |
||
52 | |||
53 | printf("\nlecroy_example: about to connect to DSO...\n"); |
||
54 | |||
55 | /* how to "set up the scope for ethernet communication" */ |
||
56 | sockfd=LECROY_TCP_connect(ip_address, MAX_TCP_CONNECT); |
||
57 | if (sockfd<0) { |
||
58 | printf("\nCould not connect to the scope on IP: %s\n",ip_address); |
||
59 | return 1; |
||
60 | } |
||
61 | |||
62 | printf("....connected.\n"); |
||
63 | |||
64 | /* example of writing to the scope) */ |
||
65 | strcpy(outbuf,"*idn?\n"); |
||
66 | LECROY_TCP_write(sockfd, outbuf); |
||
67 | printf ("Request to scope:\n%s\n", outbuf); |
||
68 | |||
69 | /* example of getting the raw data back from the scope */ |
||
70 | LECROY_TCP_read(sockfd, inbuf, sizeof(inbuf), MAX_TCP_READ); |
||
71 | printf ("Scope returned:\n%s\n", inbuf); |
||
72 | |||
73 | LECROY_TCP_disconnect(sockfd); |
||
74 | printf("Successfully disconnected... bye!\n"); |
||
75 | return 0; |
||
76 | } |