[Gambas-user] Help binding to /dev/usbtmc0?

Tobias Boege taboege at ...626...
Wed Jun 26 09:42:01 CEST 2013


On Tue, 25 Jun 2013, dr.diesel wrote:
> Hello all,
> 
> I'm trying to communicate to a Rigol spectrum analyzer, which is routed to
> /dev/usbtmc0 once connected via USB.  You can easily echo and cat serial
> commands to usbtmc0 but I'd prefer to use a socket of some sort, any
> suggestions on how to do this via gambas?
> 
> usbtmc0 has no port speed or port number so don't think I can use gambas
> sockets etc?
> 
> Basically I'd like the same functionality as a standard serial port, without
> the baud rate, parity, stop bits etc.
> 

Maybe you mistake "port" as in "serial port" and "port" as in "tcp port".
Actually /dev/usbtmc0 is a file. You cannot access it by sockets since it
has nohting to do with networking.

You should OPEN the device file and then PRINT and READ data just like echo
and cat do (the code assumes that I/O of the device file is line-based):

---
Dim hDevice As File ' No socket involved
Dim sLine As String

hDevice = Open "/dev/usbtmc0" For Input Output
' Write to it
Print #hDevice, "Command"
' Read from it
Line Input #hDevice, sLine
---

Depending on your needs, you may want to add the WATCH flag (and an event
name) to OPEN.

Regards,
Tobi




More information about the User mailing list