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

Garbled error message text #16

Open
changhexuefei opened this issue May 9, 2024 · 17 comments
Open

Garbled error message text #16

changhexuefei opened this issue May 9, 2024 · 17 comments

Comments

@changhexuefei
Copy link

image

in viOpen(): λ����Ϣ�����ϵͳ�в������豸����Դ�� (0x4000FFEE)

@changhexuefei
Copy link
Author

Here is a code example from python, it works fine and gets the correct information.

image

@changhexuefei
Copy link
Author

This is the configuration information of the serial device

image

@pfroud
Copy link
Owner

pfroud commented May 9, 2024

First, let's try to fix the garbled error message.

Can you post the full error message stack trace? I want to see which JVisa method the error happens in.

@changhexuefei
Copy link
Author

Is it this one?

image

@changhexuefei
Copy link
Author

When I was debugging, I saw garbled characters here,The value of buf is java.nio.HeapByteBuffer[pos=0 lim=256 cap=256]

image

@changhexuefei
Copy link
Author

Hello, when I switched the visa library version to visa32.dll, the garbled characters disappeared.

image

@changhexuefei
Copy link
Author

Hello, do you have a good solution to this problem?

@pfroud
Copy link
Owner

pfroud commented May 15, 2024

Right now I do not know a solution. I agree the problem happens in the byteBufferToString() method. The error code for VI_ERROR_RSRC_NFOUND should be 0xBFFF0011, I do not know what 0x4000FFEE means.

Can you open Command Prompt, run these commands:

  • java -version
  • wmic OS get OSArchitecture

then post the output

@changhexuefei
Copy link
Author

image

@pfroud
Copy link
Owner

pfroud commented May 15, 2024

I found that 0xBFFF0011 is the bitwise inverse of 0x4000FFEE. Where did you find that text which has -0x4000ffee?

Can you edit the byteBufferToString method to be this code, then run your example;

protected static String byteBufferToString(ByteBuffer buf) {
    java.nio.charset.Charset[] standardCharsets = new java.nio.charset.Charset[]{
        java.nio.charset.StandardCharsets.US_ASCII,
        java.nio.charset.StandardCharsets.ISO_8859_1,
        java.nio.charset.StandardCharsets.UTF_8,
        java.nio.charset.StandardCharsets.UTF_16BE,
        java.nio.charset.StandardCharsets.UTF_16LE,
        java.nio.charset.StandardCharsets.UTF_16
    };
    for (java.nio.charset.Charset charset : standardCharsets) {
        System.out.printf("%10s: \"%s\"\n", charset, new String(buf.array(), charset).trim());
    }
    return new String(buf.array()).trim();
}

@changhexuefei
Copy link
Author

Information found at this URL.

https://github.com/varses/awsch/blob/master/lantz/drivers/legacy/visalib.py

I have tried all methods of setting Charset, but to no avail.

@pfroud
Copy link
Owner

pfroud commented May 15, 2024

Let's try this next:

protected static String byteBufferToString(ByteBuffer buf) {
    byte[] bytes = buf.array();
    for (int i = 0; i < bytes.length; i++) {
        System.out.printf("%3d: %3d == 0x%02X\n", i, bytes[i], bytes[i]);
    }
    return new String(buf.array()).trim();
}

@changhexuefei
Copy link
Author

Now I changed the GPIB device and got the following error message when running:

0: -50 == 0xCE
1: -34 == 0xDE
2: -73 == 0xB7
3: -88 == 0xA8
4: -43 == 0xD5
5: -46 == 0xD2
6: -75 == 0xB5
7: -67 == 0xBD
8: -69 == 0xBB
9: -14 == 0xF2
10: -68 == 0xBC
11: -45 == 0xD3
12: -44 == 0xD4
13: -40 == 0xD8
14: 86 == 0x56
15: 73 == 0x49
16: 83 == 0x53
17: 65 == 0x41
18: -69 == 0xBB
19: -14 == 0xF2
20: 86 == 0x56
21: 73 == 0x49
22: 83 == 0x53
23: 65 == 0x41
24: -75 == 0xB5
25: -60 == 0xC4
26: -76 == 0xB4
27: -6 == 0xFA
28: -62 == 0xC2
29: -21 == 0xEB
30: -65 == 0xBF
31: -30 == 0xE2
32: -95 == 0xA1
33: -93 == 0xA3
34: 32 == 0x20
35: 32 == 0x20
36: -43 == 0xD5
37: -30 == 0xE2
38: -51 == 0xCD
39: -88 == 0xA8
40: -77 == 0xB3
41: -93 == 0xA3
42: -54 == 0xCA
43: -57 == 0xC7
44: -46 == 0xD2
45: -14 == 0xF2
46: -50 == 0xCE
47: -86 == 0xAA
48: -49 == 0xCF
49: -75 == 0xB5
50: -51 == 0xCD
51: -77 == 0xB3
52: -55 == 0xC9
53: -49 == 0xCF
54: -50 == 0xCE
55: -76 == 0xB4
56: -80 == 0xB0
57: -78 == 0xB2
58: -41 == 0xD7
59: -80 == 0xB0
60: -53 == 0xCB
61: -7 == 0xF9
62: -48 == 0xD0
63: -24 == 0xE8
64: -75 == 0xB5
65: -60 == 0xC4
66: -57 == 0xC7
67: -3 == 0xFD
68: -74 == 0xB6
69: -81 == 0xAF
70: -77 == 0xB3
71: -52 == 0xCC
72: -48 == 0xD0
73: -14 == 0xF2
74: -95 == 0xA1
75: -93 == 0xA3
76: 0 == 0x00
77: 0 == 0x00
78: 0 == 0x00
79: 0 == 0x00
80: 0 == 0x00
81: 0 == 0x00
82: 0 == 0x00
83: 0 == 0x00
84: 0 == 0x00
85: 0 == 0x00
86: 0 == 0x00
87: 0 == 0x00
88: 0 == 0x00
89: 0 == 0x00
90: 0 == 0x00
91: 0 == 0x00
92: 0 == 0x00
93: 0 == 0x00
94: 0 == 0x00
95: 0 == 0x00
96: 0 == 0x00
97: 0 == 0x00
98: 0 == 0x00
99: 0 == 0x00
100: 0 == 0x00
101: 0 == 0x00
102: 0 == 0x00
103: 0 == 0x00
104: 0 == 0x00
105: 0 == 0x00
106: 0 == 0x00
107: 0 == 0x00
108: 0 == 0x00
109: 0 == 0x00
110: 0 == 0x00
111: 0 == 0x00
112: 0 == 0x00
113: 0 == 0x00
114: 0 == 0x00
115: 0 == 0x00
116: 0 == 0x00
117: 0 == 0x00
118: 0 == 0x00
119: 0 == 0x00
120: 0 == 0x00
121: 0 == 0x00
122: 0 == 0x00
123: 0 == 0x00
124: 0 == 0x00
125: 0 == 0x00
126: 0 == 0x00
127: 0 == 0x00
128: 0 == 0x00
129: 0 == 0x00
130: 0 == 0x00
131: 0 == 0x00
132: 0 == 0x00
133: 0 == 0x00
134: 0 == 0x00
135: 0 == 0x00
136: 0 == 0x00
137: 0 == 0x00
138: 0 == 0x00
139: 0 == 0x00
140: 0 == 0x00
141: 0 == 0x00
142: 0 == 0x00
143: 0 == 0x00
144: 0 == 0x00
145: 0 == 0x00
146: 0 == 0x00
147: 0 == 0x00
148: 0 == 0x00
149: 0 == 0x00
150: 0 == 0x00
151: 0 == 0x00
152: 0 == 0x00
153: 0 == 0x00
154: 0 == 0x00
155: 0 == 0x00
156: 0 == 0x00
157: 0 == 0x00
158: 0 == 0x00
159: 0 == 0x00
160: 0 == 0x00
161: 0 == 0x00
162: 0 == 0x00
163: 0 == 0x00
164: 0 == 0x00
165: 0 == 0x00
166: 0 == 0x00
167: 0 == 0x00
168: 0 == 0x00
169: 0 == 0x00
170: 0 == 0x00
171: 0 == 0x00
172: 0 == 0x00
173: 0 == 0x00
174: 0 == 0x00
175: 0 == 0x00
176: 0 == 0x00
177: 0 == 0x00
178: 0 == 0x00
179: 0 == 0x00
180: 0 == 0x00
181: 0 == 0x00
182: 0 == 0x00
183: 0 == 0x00
184: 0 == 0x00
185: 0 == 0x00
186: 0 == 0x00
187: 0 == 0x00
188: 0 == 0x00
189: 0 == 0x00
190: 0 == 0x00
191: 0 == 0x00
192: 0 == 0x00
193: 0 == 0x00
194: 0 == 0x00
195: 0 == 0x00
196: 0 == 0x00
197: 0 == 0x00
198: 0 == 0x00
199: 0 == 0x00
200: 0 == 0x00
201: 0 == 0x00
202: 0 == 0x00
203: 0 == 0x00
204: 0 == 0x00
205: 0 == 0x00
206: 0 == 0x00
207: 0 == 0x00
208: 0 == 0x00
209: 0 == 0x00
210: 0 == 0x00
211: 0 == 0x00
212: 0 == 0x00
213: 0 == 0x00
214: 0 == 0x00
215: 0 == 0x00
216: 0 == 0x00
217: 0 == 0x00
218: 0 == 0x00
219: 0 == 0x00
220: 0 == 0x00
221: 0 == 0x00
222: 0 == 0x00
223: 0 == 0x00
224: 0 == 0x00
225: 0 == 0x00
226: 0 == 0x00
227: 0 == 0x00
228: 0 == 0x00
229: 0 == 0x00
230: 0 == 0x00
231: 0 == 0x00
232: 0 == 0x00
233: 0 == 0x00
234: 0 == 0x00
235: 0 == 0x00
236: 0 == 0x00
237: 0 == 0x00
238: 0 == 0x00
239: 0 == 0x00
240: 0 == 0x00
241: 0 == 0x00
242: 0 == 0x00
243: 0 == 0x00
244: 0 == 0x00
245: 0 == 0x00
246: 0 == 0x00
247: 0 == 0x00
248: 0 == 0x00
249: 0 == 0x00
250: 0 == 0x00
251: 0 == 0x00
252: 0 == 0x00
253: 0 == 0x00
254: 0 == 0x00
255: 0 == 0x00
Exception in thread "main" java.lang.RuntimeException: xyz.froud.jvisa.JVisaException: in viOpen(): �޷��ҵ������VISA��VISA�Ĵ���⡣ ��ͨ������Ϊϵͳ��δ��װ������������� (0x4000FF61)
at xyz.froud.jvisa_example.GPIBExample.main(GPIBExample.java:14)
Caused by: xyz.froud.jvisa.JVisaException: in viOpen(): �޷��ҵ������VISA��VISA�Ĵ���⡣ ��ͨ������Ϊϵͳ��δ��װ������������� (0x4000FF61)
at xyz.froud.jvisa.JVisaResourceManager.checkError(JVisaResourceManager.java:363)
at xyz.froud.jvisa.JVisaResourceManager.openInstrument(JVisaResourceManager.java:170)
at xyz.froud.jvisa_example.GPIBExample.main(GPIBExample.java:12)

@pfroud
Copy link
Owner

pfroud commented May 15, 2024

I cannot decode those bytes either

  US-ASCII: "??????????????VISA??VISA??????????  ????????????????????????????????????????"
ISO-8859-1: "�޷��ҵ������VISA��VISA�Ĵ���⡣  ��ͨ������Ϊϵͳ��δ��װ�������������"
     UTF-8: "???????????VISA??VISA??????  ???????????????????????????????"
  UTF-16BE: "?????????????????�????????????????????"
  UTF-16LE: "????????????????�????????????????????"
    UTF-16: "?????????????????�????????????????????"

@pfroud pfroud changed the title Hello, when I use JVisa to communicate with a serial device, the following error message appears. What is the cause? Garbled error message text Jul 18, 2024
@yuyangyumi
Copy link

package xyz.froud.jvisa.eventhandling;

import java.nio.charset.Charset;

public class ByteExample {
    public static void main(String[] args) {
        byte[] data = {
                -50, // 0xCE
                -34, // 0xDE
                -73, // 0xB7
                -88, // 0xA8
                -43, // 0xD5
                -46, // 0xD2
                -75, // 0xB5
                -67, // 0xBD
                -69, // 0xBB
                -14, // 0xF2
                -68, // 0xBC
                -45, // 0xD3
                -44, // 0xD4
                -40, // 0xD8
                86, // 0x56
                73, // 0x49
                83, // 0x53
                65, // 0x41
                -69, // 0xBB
                -14, // 0xF2
                86, // 0x56
                73, // 0x49
                83, // 0x53
                65, // 0x41
                -75, // 0xB5
                -60, // 0xC4
                -76, // 0xB4
                -6, // 0xFA
                -62, // 0xC2
                -21, // 0xEB
                -65, // 0xBF
                -30, // 0xE2
                -95, // 0xA1
                -93, // 0xA3
                32, // 0x20
                32, // 0x20
                -43, // 0xD5
                -30, // 0xE2
                -51, // 0xCD
                -88, // 0xA8
                -77, // 0xB3
                -93, // 0xA3
                -54, // 0xCA
                -57, // 0xC7
                -46, // 0xD2
                -14, // 0xF2
                -50, // 0xCE
                -86, // 0xAA
                -49, // 0xCF
                -75, // 0xB5
                -51, // 0xCD
                -77, // 0xB3
                -55, // 0xC9
                -49, // 0xCF
                -50, // 0xCE
                -76, // 0xB4
                -80, // 0xB0
                -78, // 0xB2
                -41, // 0xD7
                -80, // 0xB0
                -53, // 0xCB
                -7, // 0xF9
                -48, // 0xD0
                -24, // 0xE8
                -75, // 0xB5
                -60, // 0xC4
                -57, // 0xC7
                -3, // 0xFD
                -74, // 0xB6
                -81, // 0xAF
                -77, // 0xB3
                -52, // 0xCC
                -48, // 0xD0
                -14, // 0xF2
                -95, // 0xA1
                -93  // 0xA3
        };

        System.out.println(new String(data, Charset.forName("GBK")));
    }
}

It looks like the encoding is GBK, and by setting GBK encoding to parse the garbled text, I got the content: “无法找到或加载VISA或VISA的代码库。 这通常是因为系统上未安装所需的驱动程序。”

Here is the translation: “Unable to find or load VISA or VISA’s code library. This usually happens because the required drivers are not installed on the system.”

@pfroud
Copy link
Owner

pfroud commented Oct 19, 2024

Thank you yuyangyumi!

Hi @changhexuefei, does using GBK encoding work on your computer?

On my computer, I still get "???????VISA?VISA????? ????????????????????".

@changhexuefei
Copy link
Author

Yes, after using Charset.forName("GBK"), I got the correct information.

image

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

3 participants