Sending UDP command by JS

Maciej Walentowski 4 years ago updated by Vladimir Ovchinnikov (expert) 4 years ago 26

Im try to controll Ashly Pema 8250 amplifier by i3pro.
I have working commands in driver tree, but i would like to write commands in script and its don't work.

ahsly test v001.irpz

Under review


If you use Custom UDP Network, the command should look like this:

IR.GetDevice("ASHLY").Set("ASHLY UDP:WC p1 +3db","");

Read more here.

OK, so I have to define all commendsd in driver tree?

How can I read and send volume level and convert to eg. 0-100% if:

"Ashly encodes level as a 16-bit (two byte) value. This value's range is from -50.0dB to +12.0dB with tenth-dB
precision. The process for converting a value in dB to the encoded form is to take the dB value, multiply by 10,
and add 8192. For example, the encoded form of -6.3dB would be -6.3dB * 10 + 8192 = 8129. You can then
take that encoded value and convert it to the two bytes by converting to hexadecimal (0x1FC1). So the first
byte is 0x1F and the second byte is 0xC1."


You can choose one of the following options:

1) Define commands in the driver and send them using the Set method.

2) Do not define commands in the driver and send data using the Send method.

In the second case the data to be sent must be specified in the script. You can read data in the EVENT_RECEIVE_TEXT or EVENT_RECEIVE_DATA events.


Its possible to convert in script two bytes hexadecimal to one decimal value?

Im try tu use Send method (need to use hexToDec and DecToHex) but its doesn't work. What am I doing wrong?

IR.AddListener(IR.EVENT_ITEM_PRESS, IR.GetItem("Page 1").GetItem("buttonJS"), function()


IR.GetDevice("ASHLY").Send(['0xaa,0xaa,0xaa,0xaa,0x00,0x14,0xAA,0x01,0xf3,0x1b,0x64,0x65,0x66,0x61,0x75,0x6C,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x0A,0x04,0x00,0x05,0x00,0x03,0xFF', '\r\n']);

//IR.GetDevice("ASHLY").Send(['AA AA AA AA 00 14 AA 01 F3 1B 64 65 66 61 75 6C 74 00 00 00 00 00 00 00 00 00 00 01 00 00 0A 04 00 05 00 03 FF', '\r\n']);

//IR.GetDevice("ASHLY").Send(['0xaa 0xaa 0xaa 0xaa 0x00 0x14 0xAA 0x01 0xf3 0x1b 0x64 0x65 0x66 0x61 0x75 0x6C 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x00 0x00 0x0A 0x04 0x00 0x05 0x00 0x03 0xFF', '\r\n']);

IR.ShowPopup("Popup 1");


Make a delay before sending the command. In your case, the driver probably didn't have time to initialize. Select the delay experimentally. Example in the attachment.


Im try timeout 500, 1000, 1500 but doesn't work :(

what is correct syntax?


0xaa 0xaa 0xaa 0xaa 0x00 0x14 0xAA

AA AA AA AA 00 14 AA 01 F3 1B 64 65

The syntax in the project we attached earlier is correct (0xaa). The project sends data via UDP at the start with a delay. Make sure that you have UDP connections enabled on the port specified in the project. You may have a firewall blocking UDP connections.

UDP connection is correct because if I copy these syntax to command in driver tree and its works


Attach your project where you set up sending commands in channels (i.e. the project that sends the command correctly).



In your project a packet is sent from the channel:

You can use the script to send it like this:


The result will be exactly the same as in the screenshot above.

YES! :)

If I use your script its work correct. After check - in my script is ' ' before and after syntax.

IR.GetDevice("ASHLY").Send(['0xAA,0xAA,0xAA,0xAA,0x00,0x14,0xAA,0x01,0xF3,0x1B,0x64,0x65,0x66,0x61,0x75,0x6C,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x0A,0x04,0x00,0x05,0x01,0x03,0xFF', '\r\n']);

Yes, you need to send an array in the Send method. In your case, you need an array of numbers in HEX, not an array of strings.

Im try to receive data from ASHLY.

IR.AddListener(IR.EVENT_RECEIVE_DATA, IR.GetDevice("ASHLY"), function(data)




receive in ASCI, could I receive in HEX? Or convert to HEX?

How can I change status if receive: 


and change if receive:


I make it. Its possible to make easier?

IR.AddListener(IR.EVENT_RECEIVE_DATA, IR.GetDevice("ASHLY"), function(data)



if ((data) == "143,143,143,143,0,20,170,1,243,27,1,2,0,0,2,3,0,5,1,255") {



if ((data) == "143,143,143,143,0,20,170,1,243,27,1,2,0,0,2,3,0,5,0,255") {





To interpret the data received from the device, you need to refer to the documentation for the device. It is possible that interpretation via a condition, as in your example, is the solution for your case.

In documentation are:

"bytes 12-15 basically reserved by Get Parameter Header."

Sometimes byte 12 are 0, sometimes 20, 30, 100, 101 but i need rest of bytes not that.

Can you attach this documentation here?


You need to parse the resulting array using a script. This data cannot be converted to an ASCII string. For example, you only need 15-18 bytes for a string: 0x8F,0x8F,0x8F,0x8F,0x00,0x14,0xAA,0x01,0xF3,0x1B,0x01,0x00,0x00,0x00,0x02,0x03,0x00,0x05,0x00,0xFF:

var message = [0x8F,0x8F,0x8F,0x8F,0x00,0x14,0xAA,0x01,0xF3,0x1B,0x01,0x00,0x00,0x00,0x02,0x03,0x00,0x05,0x00,0xFF];
var e_15 = message[14];
var e_16 = message[15];
var e_17 = message[16];
var e_18 = message[17];
IR.Log("value Mute Option: " + e_15);
IR.Log("Number of bytes: " + e_16);
IR.Log("Channel is to be accessed: " + e_17);
IR.Log("Channel number: " + e_18);


function hexToDec (hex)
return parseInt(hex,16);
var hex_value = '1b';
var result = hexToDec(hex_value);
IR.Log("result = " + result);

Im receive data but sometimes some part of syntax in the middle (byte 12-15) are different. How can I skip it?



if ((data) == "143,143,143,143,0,20,170,1,243,27,1,2,0,0,2,3,0,5,1,255") {




What do you mean? Do you want to delete 12-15 bytes from the array?


Do you need our help at the moment?