Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JVisa whether you can read and write 16-base data? #14

Closed
Rx-out opened this issue Mar 13, 2024 · 6 comments
Closed

JVisa whether you can read and write 16-base data? #14

Rx-out opened this issue Mar 13, 2024 · 6 comments

Comments

@Rx-out
Copy link

Rx-out commented Mar 13, 2024

JVisa whether you can read and write 16-base data?
can you give an example?

@pfroud
Copy link
Owner

pfroud commented Mar 13, 2024

Please give an example of what you want to do

@Rx-out
Copy link
Author

Rx-out commented Mar 13, 2024

1710313464977

send hexadecimal data device

@pfroud
Copy link
Owner

pfroud commented Mar 13, 2024

The string "01 03 00 80 00 07" contains the character 0, then the character 1, then a space character, and so on.

Demonstration:

public static void main(String[] args) {
    printStringBytesInHex("ABCD");
    printStringBytesInHex("01 03 00 80 00 07");
}

private static void printStringBytesInHex(String str) {
    final byte[] bytes = str.getBytes(java.nio.charset.StandardCharsets.US_ASCII);
    for (int i = 0; i < bytes.length; i++) {
        System.out.printf("%02X ", bytes[i]);
    }
    System.out.println();
}

Sample output:

41 42 43 44 
30 31 20 30 33 20 30 30 20 38 30 20 30 30 20 30 37 

Table of ASCII characters:

ASCII table

I will add JVisaInstrument methods to send bytes instead of a string.

@Rx-out
Copy link
Author

Rx-out commented Mar 14, 2024 via email

pfroud added a commit that referenced this issue Mar 14, 2024
@pfroud
Copy link
Owner

pfroud commented Mar 14, 2024

You are welcome!

I added methods to write byte[] instead of String, please test it:

public void write(byte[] bytes) throws JVisaException {

Let me know if you need help getting the new code.

@pfroud
Copy link
Owner

pfroud commented Mar 25, 2024

Can you test the new method to write a byte[]?

@pfroud pfroud closed this as completed May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants