43 lines
1.5 KiB
Python
Executable File
43 lines
1.5 KiB
Python
Executable File
# -*- coding: utf-8 -*-
|
|
"""
|
|
Created on Mon Oct 10 12:41:44 2022
|
|
|
|
@author: gac-x01dc
|
|
"""
|
|
|
|
# Sends a command to the instrument
|
|
# SIM900 is the VISA resource for the SIM900
|
|
# port_number is the port number of the instrument to be controlled
|
|
# instrument_command is the command to be sent
|
|
def send_command(SIM900, port_number, instrument_command):
|
|
SIM900_command = "SNDT "+str(port_number)+", \""+instrument_command+"\""
|
|
SIM900.write(SIM900_command)
|
|
|
|
# Send a query to the instrument and get a response - CURRENTLY BROKEN
|
|
# SIM900 is the VISA resource for the SIM900
|
|
# port_number is the port number of the instrument to be controlled
|
|
# instrument_query is the query to be sent
|
|
# response_bytes is the maximum number of bytes in the response
|
|
def send_query(SIM900, port_number, instrument_query, response_bytes=7):
|
|
send_command(SIM900, port_number, instrument_query)
|
|
SIM900_command = "GETN? "+str(port_number)+", " + str(response_bytes)
|
|
full_response = SIM900.query(SIM900_command)
|
|
print("full_response="+full_response)
|
|
response = full_response[5:]
|
|
print("response="+response)
|
|
return(response)
|
|
|
|
# Flushes input & output buffers of specified port
|
|
def flush_port(SIM900, port_number):
|
|
SIM900_command = "FLSH "+str(port_number)
|
|
SIM900.write(SIM900_command)
|
|
|
|
# Flushes output queue of mainframe
|
|
def flush_main(SIM900):
|
|
SIM900_command = "FLOQ"
|
|
SIM900.write(SIM900_command)
|
|
|
|
# Resets all ports
|
|
def reset(SIM900):
|
|
SIM900_command = "SRST"
|
|
SIM900.write(SIM900_command) |