Raysot Posted February 14, 2006 Report Posted February 14, 2006 I was wondering if anyone has been successful (Using C#) in writing text to offset 0x3380 for display on the windscreen... There are currently 5 overloads for FSUIPC_Write(), but none seem to favor the writing of a string() value. Any help is much appreciated. Ray
Pete Dowson Posted February 14, 2006 Report Posted February 14, 2006 I was wondering if anyone has been successful (Using C#) in writing text to offset 0x3380 for display on the windscreen...There are currently 5 overloads for FSUIPC_Write(), but none seem to favor the writing of a string() value. The VB version had a special "FSUIPC_WriteS" foor that. I don't know VB or C# so I can't really help directly, but Pelle Liljendal is working on a revised C# section at present. You might like to write to him. See the FSInterrogate announcement above for his address. Regards, Pete
Raysot Posted February 15, 2006 Author Report Posted February 15, 2006 Thanks for the info, Peter. I'll drop him a line and see how he's doing. :D
webbm Posted February 19, 2006 Report Posted February 19, 2006 This works, but needs some tidying (such as checking for strings greater than 127 chars, error handling, etc). You'll get the idea... The answer to your question is that you need to convert your string to an array of bytes. BTW - the fsuipc object is the one included in the C# example of the SDK. Cheers, Matt. (assumes fsuipc.FSUIPC_Open has been called...) public bool WriteMessageToFS(string Message, int Duration) { int dwResult = -1; bool bResult = false; if (ConnectToFS()) { Message += "\0"; byte[] bytMessage = new byte[128]; for (int intCurrentChar = 0; intCurrentChar < Message.Length; intCurrentChar++) { bytMessage[intCurrentChar] = (byte)Message[intCurrentChar]; } lock (fsuipc) { // Set Message bResult = fsuipc.FSUIPC_Write(0x3380, 128, ref bytMessage, ref token, ref dwResult); // set Text display control word bResult = fsuipc.FSUIPC_Write(0x32FA, Duration, ref token, ref dwResult); // Write the data to FS bResult = fsuipc.FSUIPC_Process(ref dwResult); } } return bResult; }
webbm Posted March 1, 2006 Report Posted March 1, 2006 A cleaner way to convert from a string an an array of bytes: System.Text.ASCIIEncoding ASCII = new ASCIIEncoding(); byte[] bytMessage = new Byte[128]; int bytesEncodedCount = ASCII.GetBytes(Message, 0, Message.Length - 1, bytMessage, 0); Again, you'll need to check for strings greater than 128 chars...
André Gonçalves Posted January 10, 2012 Report Posted January 10, 2012 hi I need help. I'm try this: public Offset<byte[]> messageWrite = new Offset<byte[]>(0x3380,128); public Offset<int> messageDuration = new Offset<int>(0x32FA); string Message = "my message test"; byte[] datablock = new byte[Message.Length + 1]; Encoding asciiEncoder = UTF7Encoding.ASCII; asciiEncoder.GetBytes(Message).CopyTo(datablock, 0); FSUIPCConnection.Open(); this.messageWrite.Value = datablock; this.messageDuration.Value = 2; FSUIPCConnection.Process(); FSUIPCConnection.Close(); And this does not work. Presents an error write protected memory. what's wrong?
Paul Henty Posted January 10, 2012 Report Posted January 10, 2012 hi ... public Offset<byte[]> messageWrite = new Offset<byte[]>(0x3380,128); public Offset<int> messageDuration = new Offset<int>(0x32FA); ... And thisdoes not work.Presentsanerrorwrite protected memory.what'swrong? The DLL supports reading and writing of strings directly so just declare 3380 as a string type: public Offset<string> messageWrite = new Offset<string>(0x3380, 128); [/CODE] The control offset at 0x32FA is defined in the documentation as 2 bytes. You should therefore decalre this as a short, not an int (which is 4 bytes). [code] public Offset<short> messageDuration = new Offset<short>(0x32FA); The full code will something like this: public Offset<string> messageWrite = new Offset<string>(0x3380, 128); public Offset<short> messageDuration = new Offset<short>(0x32FA); string Message = "my message test"; this.messageWrite.Value = Message; this.messageDuration.Value = 2; FSUIPCConnection.Process(); Paul
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