Serial oscilloscope is connected to PC with null-modem cable to rs232 port
as modem.I want to send commands and read waweform.
1) Then using TekVisa draiver for oscilloscope i have compilling error.
2) My code in WinAPI does work with port (I can open it and setup),
But i don`t find funcion analogous for viOpen above to get Handle for Oscilloscope.
Q: how must i open session with oscilloscope.
1) Then using TekVisa draiver for oscilloscope i have compilling error.
My code is copied line by line. It gives errors Unresolved external
viOpennDefaultRM... viOpen....viClose (Include and Library paths are included
corectly):
#include"visa.h"
#include<iostream.h>
int main(int argc, char* argv[])
{
ViStatus status;
ViSession defaultRM, instr;
status=viOpenDefaultRM(&defaultRM); //Open port
status=viOpen(defaultRm, "VX10::16::INSTR", VI_NULL,
VI_NULL,&instr); //Open Oscillograph
viClose(instr);
viClose(defaultRM);
return 0;
}
2) My code in WinAPI does work with port (I can open it and setup),
But i don`t find funcion analogous for viOpen above to get Handle for Oscilloscope.
#include<windows.h>
#include<winbase.h>
#include<iostream.h>
#include<assert.h>
#define READ_TIMEOUT 1000
#define WRITE_TIMEOUT 1000
using std::cout;
using std::cin;
void setup_rs232(HANDLE hComm,DCB* dcbPtr, COMMTIMEOUTS *ctmoPtr);
int write_rs232(HANDLE hComm, char* str);
int read_rs232(HANDLE hComm);
int ErrorExit(LPTSTR lpszFunction);
DWORD dwInQueue;
DWORD dwOutQueue;
DCB dcb={0};
COMMTIMEOUTS ctmo={0};
int main()
{
HANDLE hComm;
hComm=CreateFile("COM1",GENERIC_READ|GENERIC_WRITE,
0,0,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,0);
if(hComm==INVALID_HANDLE_VALUE) ErrorExit("CreateFile");
if (! PurgeComm(hComm, PURGE_TXCLEAR | PURGE_RXCLEAR) )
ErrorExit("PurgeComm");
setup_rs232(hComm,&dcb,&ctmo); // fill DCB and COMMTIMEOTS functions
if (write_rs232(hComm,"*IDN?\n")) return 0; //trying to send command to
oscilloscope. I have error her - invalide handle
read_rs232(hComm); //trying to read answer-string with manfacture name..
CloseHandle(&hComm);
cin>>end_char;
return 0;
}
Thanks in advance!!!!