Re: Working with secondary addresses
John <[email protected]> Tue, 24 Mar 2026 23:10:16 +0000
| Newsgroups | gmane.linux.hardware.gpib.general |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format. --===============0815602640361994199== Content-Type: multipart/alternative; boundary="------------SIekGRCjqpdzJXTThXj67IHF" Content-Language: en-US This is a multi-part message in MIME format. --------------SIekGRCjqpdzJXTThXj67IHF Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Dave, Thank you, this worked perfectly fine in Perl. I did have to remove the hex() function and just use the literal 0x73 etc, but the principle of setting up a handle for each secondary command was the solution. Unfortunately I have not been able to do the same thing in Python yet. I get the following error: $ ./test_storage.py Traceback (most recent call last): File "/home/johnc/Test/linux-gpib/./test_storage.py", line 27, in <module> gpib.write(cmd_find, b'\x31\x0D') ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ gpib.GpibError: write() failed: You have attempted to write data or command bytes, but there are no listeners currently addressed. The script uses the same technique that worked in Perl so not sure what I am doing wrong at this point: #!/usr/bin/python3 import gpib import time # GPIB interface 0, address 5 con = None paddr = 5 eot = 1 # GPIB interface 0, address 5 - section added to establish the initial connection try: con = gpib.dev(0,5) except gpib.GpibError as e: print(e) exit() # GPIB interface 0, address 5 - section added to establish the initial connection cmd_find = gpib.dev( 0, paddr, 0x73, gpib.T10s, eot, 0 ) cmd_input = gpib.dev( 0, paddr, 0x6D, gpib.T10s, eot, 0x0D ) cmd_type = gpib.dev( 0, paddr, 0x66, gpib.T10s, eot, 0x0D ) # FIND file gpib.write(cmd_find, b'\x31\x0D') #INPUT first line line = gpib.read(cmd_input, 100).decode() print(line) # Close down gpib.close(cmd_find) gpib.close(cmd_input) gpib.close(cmd_type) On 24/03/2026 16:11, dave penkler wrote: > Hi John, > ibsad() does not send the secondary address but does configure it on > the device descriptor for > use in subsequent ibrd() ibwrt() calls. > Your code looks good BTW. > I'm not familiar with Perl but you might try the following to avoid > potential issues with gpib.conf: > use LinuxGpib; > $result = ""; > # setup write descriptor minor 0, pad 5, sad 27, timeout 3 secs, > assert eoi, no eos > my $devw = LinuxGpib::ibdev(0, 5, hex(0x7B), 12, 1, 0); > # setup read descriptor minor 0, pad 5, sad 13, timeout 3 secs, assert > eoi, eos = cr > my $devr = LinuxGpib::ibdev(0, 5, hex(0x6D), 12, 1, 13); > LinuxGpib::ibwrt($devw,"1\r",2); > sleep 1; > LinuxGpib::ibrd($devr,$result,100); > print $result; > print "\n"; > > cheers, > -Dave > ... > > On Tue, 24 Mar 2026 at 16:02, John <[email protected]> wrote: > > I am trying to work with secondary addresses on a storage device > using > linux-gpib. For example, I would like to read a file. The device > emulates a Tektronix 4924 tape drive and is on primary GPIB > address 5. > Normally, on a Tektronix 4051 computer I would run a find command > followed by an input command, for example: > > FIND@5:1 > > INPUT@5:A$ > > This would send a '1' to SAD 0x7B followed by SAD 0x6E to prompt the > device to send data. > > For a text file, this should read the first line of data up to a CR > terminator. > > I initially tried doing this with Python, but quickly found that > the ib* > commands in the reference do not correlate to the Python gpib module, > and that the pythin gpib module does not have methods for writing > to or > reading from secondary addresses. > > I then looked at Perl. This was far more promising, as the ib* > commands > in the reference do have a direct correlation to LinuxGpib::ib* > functions, but I could still get no output. > > This is my current Perl script. What is not clear to me is whether > ibsad() actually sends the secondary address? > > Perhaps someone can tell me whether I am going the right way about > this? > > > #!/usr/bin/perl > # Before `make install' is performed this script should be > runnable with > # `make test'. After `make install' it should work as `perl > test.pl <http://test.pl>' > > ######################### > > # change 'tests => 1' to 'tests => last_test_to_print'; > > use Test; > use Time::HiRes qw(usleep time gettimeofday); > use LinuxGpib; > > BEGIN { plan tests => 1 }; > use LinuxGpib; > ok(1); # If we made it this far, we're ok. > > ######################### > > # Insert your test code below, the Test module is use()ed here so read > # its man page ( perldoc Test ) for help writing this test script. > > $device = "Tektronix 4924"; > $cmd = ""; > $idn = ""; > $result = ""; > > my $dev = LinuxGpib::ibfind($device) || > die "Can't open device $device!\n"; > > print "FIND file .....\n"; > LinuxGpib::ibsad($dev, hex(0x7B)); > LinuxGpib::ibwrt($dev,"1\r",2); > sleep 1; > > print "INPUT first line from file .....\n"; > LinuxGpib::ibsad($dev, hex(0x6D)); > LinuxGpib::ibrd($dev,$result,100); > print $result; > print "\n"; > > print "Done.\n"; > > > # clear > LinuxGpib::ibclr($dev); > exit 0; > > > > > _______________________________________________ > Linux-gpib-general mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/linux-gpib-general > -- John. --------------SIekGRCjqpdzJXTThXj67IHF Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body> <p>Dave,</p> <p>Thank you, this worked perfectly fine in Perl. I did have to remove the hex() function and just use the literal 0x73 etc, but the principle of setting up a handle for each secondary command was the solution.</p> <p>Unfortunately I have not been able to do the same thing in Python yet.</p> <p>I get the following error:</p> <p>$ ./test_storage.py<br> Traceback (most recent call last):<br> File "/home/johnc/Test/linux-gpib/./test_storage.py", line 27, in <module><br> gpib.write(cmd_find, b'\x31\x0D')<br> ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^<br> gpib.GpibError: write() failed: You have attempted to write data or command bytes, but there are no listeners currently addressed.<br> <br> </p> <p>The script uses the same technique that worked in Perl so not sure what I am doing wrong at this point:</p> <p><br> </p> <p>#!/usr/bin/python3<br> <br> import gpib<br> import time<br> <br> # GPIB interface 0, address 5<br> con = None<br> paddr = 5<br> eot = 1<br> <br> <br> # GPIB interface 0, address 5 - section added to establish the initial connection<br> try:<br> con = gpib.dev(0,5)<br> except gpib.GpibError as e:<br> print(e)<br> exit()<br> # GPIB interface 0, address 5 - section added to establish the initial connection<br> <br> <br> cmd_find = gpib.dev( 0, paddr, 0x73, gpib.T10s, eot, 0 )<br> cmd_input = gpib.dev( 0, paddr, 0x6D, gpib.T10s, eot, 0x0D )<br> cmd_type = gpib.dev( 0, paddr, 0x66, gpib.T10s, eot, 0x0D )<br> <br> <br> # FIND file<br> gpib.write(cmd_find, b'\x31\x0D')<br> <br> #INPUT first line<br> line = gpib.read(cmd_input, 100).decode()<br> </p> <p>print(line)</p> <p><br> # Close down<br> gpib.close(cmd_find)<br> gpib.close(cmd_input)<br> gpib.close(cmd_type)<br> <br> <br> </p> <p><br> </p> <div class="moz-cite-prefix">On 24/03/2026 16:11, dave penkler wrote:<br> </div> <blockquote type="cite" cite="mid:CAL=kjP3YjqLnq9xCj6GHSAVHAQaNymeg+f18G7fh+0WDjHgjjw@mail.gmail.com"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <div dir="ltr">Hi John, <div>ibsad() does not send the secondary address but does configure it on the device descriptor for</div> <div>use in subsequent ibrd() ibwrt() calls.</div> <div>Your code looks good BTW.<br> <div>I'm not familiar with Perl but you might try the following to avoid potential issues with gpib.conf:</div> </div> <div><font face="monospace">use LinuxGpib;</font></div> <div><font face="monospace">$result = "";</font></div> <div><font face="monospace"># setup write descriptor minor 0, pad 5, sad 27, timeout 3 secs, assert eoi, no eos </font></div> <div><font face="monospace">my $devw = LinuxGpib::ibdev(0, 5, hex(0x7B), 12, 1, 0);</font></div> <div><font face="monospace"># setup read descriptor minor 0, pad 5, sad 13, timeout 3 secs, assert eoi, eos = cr </font></div> <div><font face="monospace">my $devr = LinuxGpib::ibdev(0, 5, hex(0x6D), 12, 1, 13);</font></div> <div><font face="monospace">LinuxGpib::ibwrt($devw,"1\r",2);</font></div> <div><font face="monospace">sleep 1;</font></div> <div><font face="monospace">LinuxGpib::ibrd($devr,$result,100);</font></div> <div><font face="monospace">print $result;<br> print "\n";<br> </font></div> <div><br> </div> <div>cheers,</div> <div>-Dave</div> <div>...</div> </div> <br> <div class="gmail_quote gmail_quote_container"> <div dir="ltr" class="gmail_attr">On Tue, 24 Mar 2026 at 16:02, John <<a href="mailto:[email protected]" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a>> wrote:<br> </div> <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am trying to work with secondary addresses on a storage device using <br> linux-gpib. For example, I would like to read a file. The device <br> emulates a Tektronix 4924 tape drive and is on primary GPIB address 5. <br> Normally, on a Tektronix 4051 computer I would run a find command <br> followed by an input command, for example:<br> <br> FIND@5:1<br> <br> INPUT@5:A$<br> <br> This would send a '1' to SAD 0x7B followed by SAD 0x6E to prompt the <br> device to send data.<br> <br> For a text file, this should read the first line of data up to a CR <br> terminator.<br> <br> I initially tried doing this with Python, but quickly found that the ib* <br> commands in the reference do not correlate to the Python gpib module, <br> and that the pythin gpib module does not have methods for writing to or <br> reading from secondary addresses.<br> <br> I then looked at Perl. This was far more promising, as the ib* commands <br> in the reference do have a direct correlation to LinuxGpib::ib* <br> functions, but I could still get no output.<br> <br> This is my current Perl script. What is not clear to me is whether <br> ibsad() actually sends the secondary address?<br> <br> Perhaps someone can tell me whether I am going the right way about this?<br> <br> <br> #!/usr/bin/perl<br> # Before `make install' is performed this script should be runnable with<br> # `make test'. After `make install' it should work as `perl <a href="http://test.pl" rel="noreferrer" target="_blank" moz-do-not-send="true">test.pl</a>'<br> <br> #########################<br> <br> # change 'tests => 1' to 'tests => last_test_to_print';<br> <br> use Test;<br> use Time::HiRes qw(usleep time gettimeofday);<br> use LinuxGpib;<br> <br> BEGIN { plan tests => 1 };<br> use LinuxGpib;<br> ok(1); # If we made it this far, we're ok.<br> <br> #########################<br> <br> # Insert your test code below, the Test module is use()ed here so read<br> # its man page ( perldoc Test ) for help writing this test script.<br> <br> $device = "Tektronix 4924";<br> $cmd = "";<br> $idn = "";<br> $result = "";<br> <br> my $dev = LinuxGpib::ibfind($device) ||<br> die "Can't open device $device!\n";<br> <br> print "FIND file .....\n";<br> LinuxGpib::ibsad($dev, hex(0x7B));<br> LinuxGpib::ibwrt($dev,"1\r",2);<br> sleep 1;<br> <br> print "INPUT first line from file .....\n";<br> LinuxGpib::ibsad($dev, hex(0x6D));<br> LinuxGpib::ibrd($dev,$result,100);<br> print $result;<br> print "\n";<br> <br> print "Done.\n";<br> <br> <br> # clear<br> LinuxGpib::ibclr($dev);<br> exit 0;<br> <br> <br> <br> <br> _______________________________________________<br> Linux-gpib-general mailing list<br> <a href="mailto:[email protected]" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><br> <a href="https://lists.sourceforge.net/lists/listinfo/linux-gpib-general" rel="noreferrer" target="_blank" moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.sourceforge.net/lists/listinfo/linux-gpib-general</a><br> </blockquote> </div> </blockquote> <pre class="moz-signature" cols="72">-- John.</pre> </body> </html> --------------SIekGRCjqpdzJXTThXj67IHF-- --===============0815602640361994199== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============0815602640361994199== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Linux-gpib-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-gpib-general --===============0815602640361994199==--