Anytime Help Center

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Support
  • Guest
  • Log In
English (US)
US English (US)
DE German
CN Chinese
MX Spanish (Mexico)
Chinese (Simplified)
  • AKG
    Microphones Wireless Integrated Systems Automatic Mixers Headphones Discontinued Products (AKG) General AKG Inquiries Certifications (AKG)
  • AMX
    Networked A/V Distribution (AVoIP) Traditional A/V Distribution Video Signal Processing Architectural Connectivity User Interfaces Control Processing Power (AMX) Programming (AMX) Software (AMX) Discontinued Products (AMX) General AMX Inquiries Certifications (AMX)
  • BSS
    Soundweb™ Omni Soundweb™ London Soundweb™ Contrio™ Software (BSS) Discontinued Products (BSS) General BSS Inquiries Certifications (BSS)
  • Crown
    CDi DriveCore Series CDi Series Commercial Series ComTech Series DCi DriveCore Series I-Tech HD Series XLC series XLi Series XLS DriveCore 2 Series XTi 2 Series Discontinued Products (Crown) Software (Crown) General Crown Inquiries Certifications (Crown)
  • dbx
    CX Series 500 Series DriveRack Personal Monitor Control ZonePRO Zone Controllers FeedBack Suppression Microphone Preamps Dynamics Processors Crossovers Equalizers Software (dbx) Discontinued Products (dbx) General dbx Inquiries Certifications (dbx)
  • Flux::
    Immersive Processing Analysis Subscriptions
  • JBL
    Cinema Sound Installed Live Portable Tour Sound Recording & Broadcast Software (JBL) Discontinued Products (JBL) Video Manual Series (JBL) General JBL Inquiries Certifications (JBL)
  • Lexicon
    Plugins Effects Processors Cinema Discontinued Products (Lexicon) Video Manual Series (Lexicon) General Lexicon Inquiries Certifications (Lexicon)
  • Martin
    Atomic ELP ERA Exterior MAC P3 VC VDO Tools Discontinued Products (Martin) General Martin Inquiries Certifications (Martin)
  • Soundcraft
    Digital Analog Connected Analog Only Discontinued Products (Soundcraft) Video Manual Series (Soundcraft) General Soundcraft Inquiries Certifications (Soundcraft)
  • General HARMAN Inquiries
    Dante
+ More
  • Home
  • AMX
  • Control Processing
  • IO Extenders

Controlling CE-COM2 with Python Code

Written by Gary Brindley

Updated at November 27th, 2025

​​​​The below code is used to control a CE-COM2 device. The code watches for the device to come online, configures the port, sends and receives strings, and reports faults detected on ports.


from mojo import context

context.log.info('Sample Python program')

#Create objects for the controller (idevice) and touch panel (AMX-11241)
CE_COM2 = context.devices.get("tsCE_COM2")
dvTP = context.devices.get("AMX-11241")


#Create a variable to access just the serial port
serialPort1 = CE_COM2.serial[0]


#This creates a buffer for incoming serial strings, if a string is longer than 64 characters
#it will trigger multiple events, this allows building the string until a delimiter is reached
serialBuffer = ""


#As long as the idevice is online it will set the baud rate of the serial port
if(CE_COM2.isOnline()):
    context.log.info("tsCE_COM2 online, setting baud rate.")
    serialPort1.setCommParams("9600",8,1,"NONE","232")


#If the CE-COM2 comes online after the script is running, this function will set the baud rate of the
#serial port
def ceOnline(event):
    context.log.info("tsCE_COM2 online, setting baud rate.")
    serialPort1.setCommParams("9600",8,1,"NONE","232")

CE_COM2.online(ceOnline)


#This function processes incoming strings utilizing the serialBuffer variable declared above
#Once a carriage return is seen in the string it prints what has been received
def receiveString(event):
    global serialBuffer

    serialBuffer += event.arguments['data'].decode()
    
    if (serialBuffer.find("\r") >= 0):
        print(f"Full string: {serialBuffer}")
        serialBuffer = ""

serialPort1.receive.listen(receiveString)


#An example of sending an ASCII string from the serial port
def sendASCII(event):
    serialPort1.send("ASCII string\r".encode())
    
dvTP.port[1].button[1].watch(sendASCII)


#An example of sending a hexadecimal string from the serial port
def sendHEX(event):
    serialPort1.send("\x02 \x68 \x65 \x6c \x6c \x6f \x03 \x0d".encode())
    
dvTP.port[1].button[2].watch(sendHEX)


#An example of sending a mixed hex/ASCII string from the serial port
def sendMIX(event):
    serialPort1.send("\x02 Mixed string \x03 \r".encode())
    
dvTP.port[1].button[3].watch(sendMIX)


#This function is triggered by a fault detection in the serial port, it will print out the error 
def receiveFault(event):
    context.log.info(f"Serial port fault: {event.arguments['value']}")

serialPort1.fault.listen(receiveFault)

#Leave this as the last line in the Python script
#This keeps the script running with a no-op loop, 
#maintaining the Mojo environment and access to the globals() dictionary
#For additional information search for the following article: 
#    Using context.run in MUSE Python Code

context.run(globals())

Related Videos

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • EXB ICSLAN FIRMWARE
  • CE-IRS4 Cannot Parse IR Index Information String
  • CE Series Hotfix Firmware
  • CE-COM2 Using BASE64 Encoding
  • CE-IO4 as Dry Contact

Related Articles

  • EXB ICSLAN FIRMWARE
  • CE-IRS4 Cannot Parse IR Index Information String
  • CE Series Hotfix Firmware
  • CE-COM2 Using BASE64 Encoding
  • CE-IO4 as Dry Contact
Copyright © HARMAN Professional. All rights reserved. Privacy Policy | Terms of Use
Expand