How to parse char * buffer from C to C# via dll.
The C function:
extern "C" int DLLIMPORT ReadDataSP(char *buffer, unsigned int nbChar);
The C# function
[DllImport ("SerialPort")] public static extern int ReadDataSP( [In, Out] byte[] buffer, int nbChar);
And the usage:
byte[] incomingData = new byte[1024]; SerialPortBridge.ReadDataSP(incomingData,dataLength); string s = System.Text.Encoding.UTF8.GetString(incomingData); Debug.Log(s);
No hay comentarios:
Publicar un comentario