Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

COM320 Voice Modem


IslandMan Apr 22, 2013 10:15 AM

I have a client who is using the COM320 to call out lake level alarms. He now wants to be able to set a new alarm level over the phone. I was just wondering if anyone had some code examples of this.
Thanks,
Dave


DumbleJum Sep 18, 2024 07:02 AM

To set a new alarm level over the phone using the COM320, you can typically implement a system that listens for DTMF tones (the tones generated when pressing keys on a phone) and then processes those inputs to set the alarm level. Below is a basic example of how you might structure the code:

 

import serial

# Initialize serial communication with the COM320
ser = serial.Serial('COM_PORT', baudrate=9600, timeout=1)

def set_alarm_level(new_level):
    command = f'SET_ALARM_LEVEL {new_level}\n'
    ser.write(command.encode())

def listen_for_dtmf():
    while True:
        if ser.in_waiting > 0:
            dtmf_input = ser.read(1)  # Read one byte (DTMF tone)
            process_input(dtmf_input)

def process_input(dtmf_input):
    try:
        level = int(dtmf_input.decode())
        if 0 <= level <= 100:  # Assuming alarm levels are between 0 and 100
            set_alarm_level(level)
            print(f'Alarm level set to: {level}')
        else:
            print('Invalid level. Please enter a number between 0 and 100.')
    except ValueError:
        print('Invalid input. Please enter a numeric value.')

if __name__ == "__main__":
    listen_for_dtmf()Fnaf

 

Log in or register to post/reply in the forum.