IP Adress with Socket Port #19
Unanswered
fmacraigne
asked this question in
Q&A
Replies: 11 comments 8 replies
|
Please post the error message you get |
0 replies
|
Try adding termination characters, for example: instrument.setReadTerminationCharacter('\n');
instrument.setReadTerminationCharacterEnabled(true);
instrument.setWriteTerminator("\n");
instrument.queryString("*IDN?");Here is where to check what termination character MI MAX uses: |
0 replies
|
Please post a screenshot of the I/O Settings tab in the window which opens from NI MAX |
0 replies
|
Thanks for the screenshots, they are helpful. Can you also post the Java code you are running? |
0 replies
package MSO64B.Functions;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import xyz.froud.jvisa.JVisaException;
import xyz.froud.jvisa.JVisaInstrument;
import xyz.froud.jvisa.JVisaResourceManager;
/**
*
* @author fmacraig
*/
public class MSO64B_Functions1 {
private JVisaResourceManager jvRm;
private JVisaInstrument jVisaInstrument;
public MSO64B_Functions1() {
}
public void IPOpen(String ipAdress, int port, int timeout) throws IOException, JVisaException {
try {
jvRm = new JVisaResourceManager();
jVisaInstrument = jvRm.openInstrument("TCPIP0::168.192.0.114::5005::SOCKET");
jVisaInstrument.setTimeout(timeout);
jVisaInstrument.setReadTerminationCharacter('\n');
jVisaInstrument.setReadTerminationCharacterEnabled(true);
jVisaInstrument.setWriteTerminator("\n");
} catch (JVisaException | UnsatisfiedLinkError ex) {
Logger.getLogger(MSO64B_Functions1.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* Fonction de fermeture du socket
*
* @throws IOException
*/
public void IPclose() throws IOException {
try {
jVisaInstrument.close();
} catch (JVisaException ex) {
Logger.getLogger(MSO64B_Functions1.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
*
* @param iMeas
* @param iTrace
*/
public void getSpectrum(int iMeas, int iTrace) {
String sReponse;
String sCommand;
sCommand = "*IDN?\n";
try {
sReponse = jVisaInstrument.queryString(sCommand);
System.out.println(sReponse);
} catch (JVisaException ex) {
Logger.getLogger(MSO64B_Functions1.class.getName()).log(Level.SEVERE, null, ex);
}
}
} |
0 replies
|
Try removing sCommand = "*IDN?"; |
1 reply
|
Let's compare all the Visa attributes between NI MAX and our program, can you run this right before sending System.out.println("RSRC_NAME " + instrument.getAttributeString(JVisaLibrary.VI_ATTR_RSRC_NAME));
System.out.println("INTF_TYPE " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_INTF_TYPE)[0]);
System.out.println("RSRC_CLASS " + instrument.getAttributeString(JVisaLibrary.VI_ATTR_RSRC_CLASS));
System.out.println("TCPIP_HOSTNAME " + instrument.getAttributeString(JVisaLibrary.VI_ATTR_TCPIP_HOSTNAME));
System.out.println("TCPIP_ADDR " + instrument.getAttributeString(JVisaLibrary.VI_ATTR_TCPIP_ADDR));
System.out.println("TCPIP_PORT " + Arrays.toString(instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_TCPIP_PORT)));
System.out.println("TCPIP_NODELAY " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_TCPIP_NODELAY)[0]);
System.out.println("TCPIP_KEEPALIVE " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_TCPIP_KEEPALIVE)[0]);
System.out.println("TMO_VALUE " + Arrays.toString(instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_TMO_VALUE)));
System.out.println("SEND_END_EN " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_SEND_END_EN)[0]);
System.out.println("SUPPRESS_END_EN " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_SUPPRESS_END_EN)[0]);
System.out.println("TERMCHAR_EN " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_TERMCHAR_EN)[0]);
System.out.println("TERMCHAR " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_TERMCHAR)[0]);
System.out.println("IO_PROT " + instrument.getAttributeBytes(JVisaLibrary.VI_ATTR_IO_PROT)[0]); |
1 reply
|
Thanks for posting the result. It looks all the values from your code match the values in the NI I/O Trace screenshot. I will keep thinking of ways to debug this problem |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Hello,
I try to use IP adress with Socket Port like : "TCPIP0::10.10.0.8::5025::SOCKET", but i have an error message of connection as soon as I run the "openInstrument" command.
Could you help me to try a solution ?
Kind Regards
All reactions