Advantech ADAM Module with serial, need help

I am trying to read and command a ADAM 4050 I/O module is uses ASCII commands over RS485 serial there are 7 inputs and 8 outputs on the device.

Here is an example read command from the datasheet.

command: $336(cr)
response: !112200(cr)
This example is for ADAM-4050. The first two characters,
11h (00010001), of the response indicates that digital
output channels 0 and 4 are ON and channels 1, 2, 3, 5, 6, 7
are OFF. The second two characters of the response, 22h
(00100010), indicates that digital input channels 1 and 5 are
HIGH and channels 0, 2, 3, 4, 6, 7 are LOW.

and here is an out command.

command: #151201(cr)
response: >(cr)
An output bit with value 1 is sent to channel 2 at address
15h of a digital I/O module (Either ADAM-4050 or
ADAM-4060).
Channel 2 of the digital I/O module is set to ON.

I just can’t seem to wrap my head around the serial binding in OpenHAB unfortunately I can find very little examples on working implementations here or on the wiki. I also have a Gentner audio switcher that uses serial sitting on the shelf collecting dust because I can figure out how to send commands in serial.

I am currently trying to use

.ITEMS

String ADAM_4050 {serial="COM14@9600"}
Switch Roll_1_UP

.RULES

rule	"ADAM 4050 D0"
when 	Item Roll_1_UP received update
then	
	if(Roll_1_UP.state==ON) {
		sendCommand(ADAM_4050,"#051001")
	}
		else {
			if(Roll_1_UP.state==OFF) {
				sendCommand(ADAM_4050,"#051000")
			}
		}
end

it shows in the log that ADAM_4050 is being updated with the string but nothing is happening in the device. I can send the same commend over serial terminal and see it work.

ok let me start with a stupidity admission… It does help when setting up a binding that the actual binding file is in the addon folder. That said this is what I have gotten to work so far.

.RULE

rule	"ADAM 4050 D0"
when 	Item Roll_1_UP received update
then	
	if(Roll_1_UP.state==ON) {
		sendCommand(ADAM_4050,"#051001" + "\u000D")
	}
		else {
			if(Roll_1_UP.state==OFF) {
				sendCommand(ADAM_4050,"#051000" + "\u000D")
			}
		}
end

rule	"ADAM 4050 D1"
when 	Item Roll_1_Down received update
then	
	if(Roll_1_Down.state==ON) {
		sendCommand(ADAM_4050,"#051101" + "\u000D")
	}
		else {
			if(Roll_1_Down.state==OFF) {
				sendCommand(ADAM_4050,"#051100" + "\u000D")
			}
		}
end

I still do not know how to

    sendCommand(ADAM_4050,"!056" + "\u000D")

and dissect the binary data into contacts or switches so I can read the inputs.