HS and RS-232 with AB8SS

Rustytek

Active Member
I have an AB8SS (HACS speaker selector) and want to control the changing of speakers through scripting. I know I could pay 30.00 for the plugin but I would rather program it into my scripts. The problem is I have no idea how to read and write data to the com ports. I have no problem opening and closing the problem is sending the data.

THis is primary script

sub main()
status=hs.OpenComPort(6,"9600,n,8,2",1,"com6_event.txt","main")

if status <> "" then
hs.writelog "Error","Comm port 6 could not be opened"
end if

'HOW DO I SEND THIS INFORMATION?
hs.SendToComPort 6,"!8400007C*"



end sub

With Calling Script "Com_6_event.txt"


sub main(dataFromCom3)
hs.writelog "Received",dataFromCom3
end sub
 

smee

Senior Member
I don't have time right now to help, but I'll try and get back later if nobody else replies. Serial stuff in HS is pretty easy.

I just wanted to mention that you may find it's more work than you expect to control the AB8SS. If I recall correctly [1], the communications protocol requires a lot of handshaking. You can't just send a message. You need to send one character at a time and wait for acknowledgement from the AB8SS before you send the next.

I know I've discussed this with people before. There's probably a thread or two here or on the HS boards covering some of it.

[1] and I may be thinking of the multiplexor (AB8X8 ?) instead of the AB8SS.
 

Rustytek

Active Member
I can follow your elk script (somewhat) but still a little slow with sending commands. My intention is to learn to send the command's simply and then build upon that. From what I gathered from the ElK script is that CRC error checking is required but I still am not sure how to send the commands. From the HACS website I can see that each command is sent and then echoed back. The protocol is as follows:

9600 baud
1 start bit
8 data bits
2 stop bits
no parity

Thanks for the help so far, but I am still not quite understanding how to send data.

I have searched all of the homeseer forums and none of the devices and sample code are quite the same.
 

electron

Administrator
Staff member
the crc checking is part of the Elk protocol, so it isn't required. But if smee is right (and he always is :unsure:), then it is going to be much more complicated to send serial data than using a single sendtocomport command.
 

deranged

Active Member
I am by no means a programmer, I have said it a thousand times. But when I want to do something bad enough I learn enough to accomplish the task.

I have a script for the HACS AVS8x8 that would probably be a value for you to look at.

I am sure most programmers will get a good laugh out of the script and find many flaws or better ways to do things. But currently the script works fine for me.

I should also point out I am not afraid of any criticism.... :rolleyes:

So maybe these will get you started in the right direction.

I write myself docs for everything because I will never be able to remember what the heck I did.

I had to save the docs as a pdf because I couldn't get the text to show up right.



StevenE
 

Attachments

  • avs8x8_readme_docs.pdf
    11.8 KB · Views: 81
Top