RIGOL Programming Example
Programming Guide for DS1000CA Series
viSetAttribute (vi, VI_ATTR_TERMCHAR, 0xA);
viSetAttribute (vi, VI_ATTR_TERMCHAR_EN, VI_TRUE);
//5. Set up baud rate, stop bits and so on
viSetAttribute (vi, VI_ATTR_ASRL_BAUD, 9600); //Baud rate
viSetAttribute (vi, VI_ATTR_ASRL_DATA_BITS, 8); //Data Bits
viSetAttribute (vi, VI_ATTR_ASRL_STOP_BITS, VI_ASRL_STOP_ONE); //Stop
bits
viSetAttribute (vi, VI_ATTR_ASRL_PARITY, VI_ASRL_PAR_NONE); //No
vertification
// send the receiving commands
m_combox.GetLBText(m_combox.GetCurSel(),strTemp);
sprintf( buf,"%s\n",strTemp.GetBuffer(10));
viWrite( vi, (unsigned char*)(&buf), strTemp.GetLength()+1, &retCount );
//Read the results
viScanf(vi,"%t\n",&buf );
m_receive = buf;
UpdateData (FALSE);
viClose (vi);
viClose (defaultRM);
Explanations*:
Pay attention to the following matters when adopts serial port communication.
(1) Set up a suitable bus timeout to avoid error communication cased by lower serial
communication speed.
(2) In order to make a succesfull commnuication, settings of the serial port
communication which contain baud rate, data bits, stop bits and parity check
bits should be the same as oscilloscopes.
(3) During reading data by serial port, system will stop rading data when VISA
meets end mark “0x0A”. Please note this phenomenon when appears 0x0A. In
addition, length of reading data is a standard to judge whether data aception is
over.