Posted 10 months ago by L, Georg
I found a very usefull example how to perform measurements and transfer data: 

https://github.com/tektronix/keithley/tree/main/Instrument_Examples/DMM7510/Stream_Digitized_Measurements/Sockets/Single_Box

Python
  1. def get_block(my_socket, chunk_size, buffer_size):
  2. # This function extracts the binaray floating point data
  3. # from the DMM7510.
  4. sndStr = "get_data({0})\n".format(buffer_size)
  5. my_socket.send(sndStr.encode())
  6. response = my_socket.recv(1024)
  7. # New content....
  8. fmtStr = '%df' % chunk_size
  9. altResp = struct.unpack(fmtStr, response[2:-1])
  10. return altResp

TSP
  1. function get_data(buffSize)
  2. chunker = 249
  3. --while buffer.getstats(defbuffer1).n - readings_captured < 200 do
  4. while (buffer.getstats(defbuffer1).n - readings_captured) < chunker do
  5. delay(0.001)
  6. end
  7. local index1 = math.mod(readings_captured, buffSize) + 1
  8. local index2 = index1 + (chunker - 1) -- was 199
  9. if index2 > buffSize then
  10. index2 = buffSize
  11. end
  12. --print(scpi.execute(':TRAC:DATA? ' .. index1 .. ', ' .. index2 .. ', \"defbuffer1\"'))
  13. printbuffer(index1, index2, defbuffer1.readings)
  14. readings_captured = readings_captured + chunker
  15. end

How shall I change those blocks to get relativetimestamps as well?
Posted 8 months ago by C, Andrea
The printbuffer() can take multiple buffer elements:
printbuffer(index1, index2, defbuffer1.readings, defbuffer1.relativetimestamps)

This well result in comma delimited reading, time, reading, time, etc according to the index values.
The receiving code will need to parse it.

You must be signed in to post in this forum.