kikigey89 Posted October 24, 2007 Report Posted October 24, 2007 Hi everybody, is it possible to generate a text message with FSUIPC like this one? http://www.christophpaulus.com/msg.jpg Greetings from Germany
Pete Dowson Posted October 24, 2007 Report Posted October 24, 2007 is it possible to generate a text message with FSUIPC like this one? http://www.christophpaulus.com/msg.jpg Yes. You send the message as a normal ASCIIZ string to offset 3380, then write a control word to 32FA which specifies stuff like time of display and whether it scrolls or not. Please see the FSUIPC SDK. Regards Pete
kikigey89 Posted October 25, 2007 Author Report Posted October 25, 2007 I don't know why, but it doesn't work. This is my source code for VB: Dim test As String Dim control As Integer test = "hello!" control = 0 If FSUIPC_Write(&H3380&, 128, VarPtr(test), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If If FSUIPC_Write(&H32FA&, 2, VarPtr(control), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If Does anybody has an idea?
Thomas Richter Posted October 25, 2007 Report Posted October 25, 2007 I don't know why, but it doesn't work.This is my source code for VB: Dim test As String Dim control As Integer test = "hello!" control = 0 If FSUIPC_Write(&H3380&, 128, VarPtr(test), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If If FSUIPC_Write(&H32FA&, 2, VarPtr(control), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If Does anybody has an idea? Hi I use it vice versa and it works perfect. First writing 32FA, following by 3380.
Pete Dowson Posted October 25, 2007 Report Posted October 25, 2007 I use it vice versa and it works perfect. First writing 32FA, following by 3380. But it most certainly shouldn't work that way. The display is activated when you write to 32FA. Nothing happens when you write to 3380. Maybe you are repeating it? I don't know why, but it doesn't work.This is my source code for VB: First, the call "FSUIPC_Write(&H3380&, 128, VarPtr(test), dwResult)" is wrong because the string is not 128 bytes long. You must give the actual length, including the terminating zero byte. Second, though I don't know VB, the usual sort of reason for this problem was that VB didn't use ASCIIZ strings, but either Wide or Unicode strings, so that string wouldn't be correct. Additionally, an ASCIIZ string should be zero terminated, whereas aren't VB strings preceded by a length byte? If that is some odd control character, that would wreck the string as well. Please use the Logging facilities in FSUIPC to see exactly what is being written. That is why I provided logging, to help folks debug their code, yet no one seems to bother to take advantage of this! :-( Regards Pete
kikigey89 Posted October 26, 2007 Author Report Posted October 26, 2007 Now it works! First, I forgot to initialize FSUIPC... I could beat myself... Second, I found a way to avoid the string-problem: Dim msgString As String Dim msgPos As Integer msgString = "welcome" FSUIPC_Initialization If FSUIPC_Open(SIM_ANY, dwResult) = True Then For msgPos = 1 To Len(msgString) If FSUIPC_Write(13183 + msgPos, 2, VarPtr(Asc(Mid(msgString, msgPos, 1))), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If Next msgPos If FSUIPC_Write(&H32FA&, 2, VarPtr(5), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If End If
Pete Dowson Posted October 26, 2007 Report Posted October 26, 2007 Second, I found a way to avoid the string-problem: For msgPos = 1 To Len(msgString) If FSUIPC_Write(13183 + msgPos, 2, VarPtr(Asc(Mid(msgString, msgPos, 1))), dwResult) Yes, that will work (though you should add a zero character to the end -- if you don't any previous longer message will leave part of itself appended to yours when displayed). But: it is not very efficient. Each time you add another character you are creating another "write block" with a 16-byte header. That makes the data being transferred nearly 17 times larger than it should be. Worse, when it gets to FSUIPC, each of those writes is processed separately, taking valuable FS processor cycles. Better to formulate the string correctly in your own area first. If VB doesn't come with a way of converting its strings for normal Windows API ASCIIZ format already (which would surprise me), then declare a work area as an array of 128 bytes and do the loop for the string length preparing that array. Add the zero at the end, then do the single FSUIPC_Write from the array with a length+1. Regards Pete
kikigey89 Posted October 26, 2007 Author Report Posted October 26, 2007 Yes, I know that this is not the best solution, so I will try to improve it in the next days. The problem is, that I found nothing about ASCIIZ in VB.
kikigey89 Posted October 26, 2007 Author Report Posted October 26, 2007 Now it's finished: Declaration: Private AsciiZ() As Byte Function: Public Sub writeMsg(msgString As String, msgControl As Integer) msgString = msgString & Chr(0) AsciiZ = StrConv(msgString, vbFromUnicode) FSUIPC_Initialization If FSUIPC_Open(SIM_ANY, dwResult) = True Then If FSUIPC_Write(&H3380&, Len(msgString), VarPtr(AsciiZ(0)), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If If FSUIPC_Write(&H32FA&, 2, VarPtr(msgControl), dwResult) Then If FSUIPC_Process(dwResult) Then End If End If End If End Sub
Pete Dowson Posted October 26, 2007 Report Posted October 26, 2007 Now it's finished:... AsciiZ = StrConv(msgString, vbFromUnicode) Aha, so there is a function for it! That's good, and I did really think there should be! Well done, Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now