The church I go to has a data projector (Toshiba TDP-S20) that can be controlled via a serial connection. When it was installed, we connected the projector to the nearest PC (runnings Windows XP) and I found a RS232 software program online that allowed me to control it successfully. To power up the projector, I found I could send the following string of characters:
BlackSmileyFace + PON + BlackHeartSuit (without the plus signs and spaces)
I was able to put the symbols into the transmit textbox by right-clicking within the transmit textbox and choose the symbols from a pop-up ASCII table. I'd click on the Send button and everything was fine.
A few days ago I decided to build a windows app in VB.NET that would allow us to control the projector using various buttons, each button controlling one of the functions like POWER ON, SHUTDOWN, INPUT1, INPUT2, etc, etc. In each case the string of characters needed started with the Black Smiley Face and ended with the Black Heart Suit symbol.
BlackSmileyFace + PON + BlackHeartSuit
BlackSmileyFace + IN2 + BlackHeartSuit
I'm developing the program from my Home Office computer using Visual Studio 2008. The PC used to control the projector and the projector are at a different location.
Simply put, I thought I had it all figured out when I could click on my Power On button and the correct string of characters would appear in my "Code Sent" textbox. I would see the BlackSmileyFace, the string of three function characters (PON, for example) and the BlackHeartSuit symbol. I used the following VB.Net code to get the correct characters to display in my CodeSent textbox on my development PC.
Expand|Select|Wrap|Line Numbers
- Dim BlackSmileyFace As Char
- Dim BlackHeart As Char
- BlackSmileyFace = ChrW("9787")
- BlackHeart = ChrW("9829")
- CodeSent.Text = BlackSmileyFace + "PON" + BlackHeart
Expand|Select|Wrap|Line Numbers
- If moRS232.IsOpen Then
- Dim outgoing as string
- outgoing = CodeSent.Text
- moRS232.WriteLine(outgoing)
- End If
Next, I decided to open the RS232 terminal program I had successfully used to control the projector, enter the Power On command in that program's transmit textbox (using the ASCII table to enter the BlackSmileyFace and BlackHeartSuit symbols in the proper place) and copy that string of characters to my clipboard. I did so.
I pasted that string of characters from my clipboard into my program's CodeSent textbox, clicked on my SEND button and the projector turned on.
I pasted what was in my clipboard into NOTEPAD, copied that, pasted that into my programs CodeSent textbox, clicked on my SEND button and the projector turned on. I then changed the three function command characters (between the two symbols) in my open notepad file to IN1 - to change the projectors input to Input #1 - copied the revised notepad code, pasted it into my CodeSent textbox, clicked on the SEND button and the projector responded appropriately.
So, for some reason, when I try to send the start and stop part of my command code to the projector using ChrW() and sending the command as a string, it doesn't work.
SUMMARY:
This does not work, even though it appears to be display correctly on my development PC:
Expand|Select|Wrap|Line Numbers
- BlackSmileyFace + PON + BlackHeartSuit
I can grab what appears to be exactly the same command string from the working RS232 terminal program and it does work.
I can grab what was copied into or edited within NOTEPAD (the symbols do not appears as the Black Smiley Face and the Black Heart Suit) and that will work in my program.
I wish I could see the code behind what was displaying in NOTEPAD and the working, third-party, RS232 terminal program.
I know that the serial port is opening and closing correctly within my program. I am using the SerialPort class.
Given the above, what VB.NET code would you suggest I use to write the correct command to the projector?
Thanks for your help.