Please select To the mobile version | Continue to access the desktop computer version

Electronic Engineer Discuss

View: 177|Reply: 2

DSO4254C standard SCPI commands with usbtmc (Linux)

[Copy link]

4

Threads

9

Posts

9

Credits

新手上路

Rank: 1

Credits
9
Post time 2020-5-13 11:11:21 | Show all posts |Read mode
Edited by krjdev at 2020-5-13 11:22

Hello,

I'm trying to control the DSO with a Linux PC using the builtin usbtmc driver.

Is there a list of the standard IEEE488 commands which the DSO supports?
Tried the *IDN? command first, but currently only get 2 bytes from the DSO.
But could be an issue in my current code.


Can somebody post a full example output of the IDN command please? Well it should look like?





Reply

Use magic Report

4

Threads

9

Posts

9

Credits

新手上路

Rank: 1

Credits
9
 Author| Post time 2020-5-14 01:31:53 | Show all posts
Edited by krjdev at 2020-5-14 01:38

Okay the following simple code returns the device id string:

  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <unistd.h>
  4. #include <string.h>

  5. int main(int argc, char *argv[])
  6. {
  7.     int fd;
  8.     unsigned char buf[1024];
  9.     int ret;
  10.     int flags;
  11.    
  12.     fd = open("/dev/usbtmc0", O_RDWR);
  13.    
  14.     if (fd == -1) {
  15.         printf("Could not open device\n");
  16.         return 1;
  17.     }
  18.    
  19.     flags = fcntl(fd, F_GETFL, 0);
  20.     fcntl(fd, F_SETFL, flags | O_NONBLOCK);
  21.    
  22.     ret = write(fd, "*IDN?\n", strlen("*IDN?\n"));
  23.    
  24.     if (ret == -1) {
  25.         printf("Could not write to device\n");
  26.         close(fd);
  27.         return 1;
  28.     }
  29.    
  30.     sleep(1);
  31.    
  32.     ret = read(fd, buf, 1024);
  33.    
  34.     if (ret == -1) {
  35.         printf("Could not read from device\n");
  36.         close(fd);
  37.         return 1;
  38.     }
  39.    
  40.     buf[ret] = '\0';
  41.     printf("%s\n", buf);
  42.     close(fd);
  43.     return 0;
  44. }
Copy the Code


The output:

  1. $ ./dso
  2. Hantek, DSO4254C, CN1830002001956, 1.1.2(191026.0)
  3. $
Copy the Code




9

Threads

125

Posts

125

Credits

注册会员

Rank: 2

Credits
125
Post time 2020-5-15 08:29:15 | Show all posts



Have you checked the download files on the product's page? I think you will find what you want there.

http://www.hantek.com/en/ProductDetail_3_12167.html
You have to log in before you can reply Login | Register

Points Rules

QQ|Dark room|Mobile|Archiver|Electronic Engineer Discuss

2020-6-2 02:32 GMT+8 , Processed in 0.479467 second(s), 21 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

Quick Reply To Top Return to the list