05-18-2021 02:51 AM - edited 05-18-2021 02:52 AM
First in g̸̨͕̭̟̻̥͕͙̳͔̬̥̬͈̃̈́̐̐͐̈̒̌̍̀̊͆̐͆̈͑͛͒͌͗͒̓̉̎̈́̒̉͐̀̐̈́̆̃̑̂̿́̏̚̕̕̕͜͜͠͠͠a̸̧̧̡̡̡̛̛͕̝͇̭̪̫̘͇̘͈̣͕͖̜̬͎̘̯̖̻͖̠̤̩̗̣̝͕͙̝̻̰͍̰̖͇͔̱̲͚̹͚̠̟̥̗̞͚͚̭͚͔͎̞̹̝͇̱̗͌͌͆͆̒́̀̍̄̉̊̈́̐̆́͂̈́̄͑́̉͛̓̑̄͑̃̔͂̂̐̉̽͒̓̂̿̅͋̒̍̆͐̌̔̉̓͂̐̒̑̉̆̐̆͒̈̏̐̓̑͆́̀̓̚̕̚̚̚͝͝r̸̡̡̡̡̨̛͎͓͉̦̰̖͚̙̳̯͕̻̬̠̮̣̘̭͙̦͇͍̱̲̮̫̞͖͇̻̹̺͔̼͈̺̰̙͔̮̘̝̝̲̪̹̤͕̲̮͎͔͕͎̂̌̇̅̀̈́͂̉̈͒͆̉̔̓͌̎̈̑́̐͐̋͋̆́̑̐̄̈͒͗̿̔̈́̈͌́̎̔̾̾̕̕͘͘͘͝͝͝͠͝͝͝͠ͅḇ̵̡̧̛̛̭̹͚̯̱̣̖͓̺͍̻̯͍̮̥̼̳͇̼̬̗͖̙̖̻̣͈̙͓̠̼͓̘̦̦͚̰̫͖̜̫̫͔͍̫̂̈͛̓͑̌͂̋̽͗̄̀͛̃̀̏͒͛̀̌̅̈́͗͑͌̓͌͌͑́̈́́̇̇̓́̀̋͋̌͘̚͘͝͝͝ͅa̴̢̡̧̡̧̛̛̼̣̟̻͔̬̫̬̟̟͇̳̳̞̭̥̞̬̣͙̬̤̲͈̝̭̭͈͔̜̣͖̫̳͖̝̖̙̟̬̦̙̫̺͔͇̲͎̟̖͎̝͂͆̄̅̊̎̀͗͒͗̌̓͗̈́̀̄͗͋͆̋̓̈́̈́͌̉̑͐̓͒͑̈̌͑̉͑̽͒̉̂͛̋́̎̐̓͋͐͛̉̓̃͋̇̅̐̈́̀̑̂̍̀̕̕͘͝͝͝͠͝ͅͅg̶̡̨̢̡̙̻͓̤̟̯̯̭̗̠͓̝̟̮̥̮̹̖͙̯̝͖͍̯͙̪̹̹̝̯̲̪͚̦̙̹̰̳̯͙̮̮̼̝͙̣̳̞̮̓̊̈́͂̉́̏̃͐̾̋͒́͂̍̏̀̈́̒̄̒͘͘͜͝͠͝ͅͅͅę̷̢̧̻̞̭͉̮̱̳͉̦͕̠̰̬̝̖̹̞̟͍͕̳̰͉̩̘͚̩͓͉͈̗͔͕̣̳̘̭̘̮͎̂͋̉͑̇̎̄͌̑̄̂̀͒̈̌͂̊̀̈̃͘͘͜͜͠ ̷̨̧̡̝͎̣̝̱̞͈̲̬̦̟̬̭̥̮̮͚̥͉͖̺̬̟̘̼̲̻̭̟̹͙̮̪̱̫͚̦̺́͛̈́́̍̈́̄̋̎̊͋̆̑͌́̊̐́̉̇̍͊̍͊́̆̇̓̎͊̑̋͛̏̀̈́̒͛̈̿̅̉̎̒̓͘̕̚̕̕̚̚͜͜͠͝ͅo̷̡̙̞̻̩̜̘̪͚̳̙̟̤̻̫͔̰̟̼̲̘̱͍̟̠̼̯͎̭͍̙̖̺̦̟̝̳̺̳̰̣̱̹̰̮̞͊̈́͒͜ͅư̷̛͖͉̠͔͍͉͎̳̖̲̞̖̳̭̯̥̙̖̯̙̪̗̖̱̔͑̋̆̋̀̄̆̾̊͛̃͗̅͗̌̑̆̏̽̈́́̓͑̈́͒̓̊͐͗́̋̌̈́̋̈̽́̎̏̈́͌͒̊̌̈́̆̀̔̎͛͘̕̚̚̕̕͜͜͜͠͝͝ͅt̵̨̻̳̘̻͇̬̟̩̥͓͚͕̍̇̇̔̌̓̐̐̓̿̂͛̂͑̃͊̓̾̈́́͒͋̏̈́̂̐̀́̌̀͊͛̽̈̚̕͜͝
05-18-2021 03:07 AM
when I create a program such as SVI-TARESETUP attached, with a single command, it is the correct output that is read into the read buffer.
When I create the same thing with another command and put them in a row, then the responses get mixed up.
I attach my last test which is a sequenced program that is supposed to ask the second condition only after the first condition is done.
The result is that the answer in the output buffer of the first loop: TARESETUP is XPa or other possible answers. While the question is supposed to arrive only afterwards. I don't know what to think. Indeed it is very strange.
Translated with www.DeepL.com/Translator (free version)
05-18-2021 03:28 AM
Could it be that one command returns multiple lines?
That could confuse things.
If you only read one line of the answer, the next command will appear to return a random answer. This will only get weirder. The 2nd cycle, the first command that worked before now returns random answers as well.
05-18-2021 04:26 AM
each command reads only one line. I wonder if this has anything to do with an offset in the response and memory, do you know how the number of bytes should be configured?
05-18-2021 04:47 AM
@aerosimon ha scritto:
each command reads only one line. I wonder if this has anything to do with an offset in the response and memory, do you know how the number of bytes should be configured?
You mean for the VISA Write? You simply wire a number greater than the number of bytes you expect to receive, then rely on the Termination Character you configured for the port. Obviosuly, if the answer does contain more than one Termination Character, you must read multiple times accordingly.
05-18-2021 07:43 AM
@aerosimon wrote:
each command reads only one line. I wonder if this has anything to do with an offset in the response and memory, do you know how the number of bytes should be configured?
Lots of scales can be programmed to output data by itself.
Maybe that's what's going on?
Historically, lots of scales could connected to a printer.
I'd read the manual 4 or 5 times, to see if this is plausible, and if it can be turned off. IIRC some brands need physical key pressing to turn this off (and on).
05-19-2021 12:58 AM
what do you mean by "more than one termination character"? for example, 4 bytes came out of my first command. But I always put 2500 bytes to my read no matter what. Is this an error?
05-19-2021 01:08 AM
I read the manual several times and did keyword searches in the text, I couldn't find anything that would match this.
05-19-2021 01:16 AM
Several others suggested this before but i don't think you've tried it.
Send only one command and read the answer. Add a delay so you write/read every 100ms or so and not constantly.
If the answer you get is the expected one, change the command you are sending and repeat the process until you go through all commands you intend to use.
Only after all commands work as intended, should you do what you are doing now and send them in sequence.
05-19-2021 01:36 AM
@aerosimon ha scritto:
what do you mean by "more than one termination character"? for example, 4 bytes came out of my first command. But I always put 2500 bytes to my read no matter what. Is this an error?
No, it's not. I can't open your vi, so I don't see how you configured the serial port. What I mean is the following.
Let's say the termchar is the newline, the default (\n = ASCII 10). Let the expected response be "OFF\n". You require 2500 bytes but VISA Read stops as soon as it receives the newline. Whats really important here is that 2500 (requested bytes) >= 4 (received bytes).
Should the response be "OFF\n19 Pa\n" instead, it would contain two newlines, so you would need to read twice. You would receive first "OFF\n" and then "19 Pa\n".