Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

CLR E Wrong Type?


Best Answer Chris Walker , 14 March 2014 - 03:45 AM

Hi idlegoose007,

Is the data in the byte array a valid UTF8 string?

Can you copy and paste a sample bad byte array here? The function is working properly, needs to be tweaked to fail silently, or isn't handling all UTF8 strings properly.

Chris Go to the full post


  • Please log in to reply
1 reply to this topic

#1 idlegoose007

idlegoose007

    Member

  • Members
  • PipPip
  • 11 posts

Posted 13 March 2014 - 11:09 PM

This was working fine but for some reason has quit working. I can see all 512 members in the debugger when it halts. I am using 4.1 on the Mini.
 
#### Exception System.Exception - CLR_E_WRONG_TYPE (3) ####
#### Message: 
#### System.Text.UTF8Encoding::GetChars [IP: 0000] ####
#### Cortana.MTK3339::ProcessData [IP: 006e] ####
#### Cortana.MTK3339::DataReceived [IP: 00b0] ####
#### System.IO.Ports.SerialPort::DataEventHandler [IP: 0016] ####
A first chance exception of type 'System.Exception' occurred in mscorlib.dll
An unhandled exception of type 'System.Exception' occurred in mscorlib.dll
 
occurs in these lines of code.
             lock(readBuffer)
Error-> char[] buffer = Encoding.UTF8.GetChars(readBuffer);
 
*readBuffer is an array of bytes of a set size (512)
 
As a workaround I used a for loop: buffer[i] = (char)readBuffer[i];


#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 14 March 2014 - 03:45 AM   Best Answer

Hi idlegoose007,

Is the data in the byte array a valid UTF8 string?

Can you copy and paste a sample bad byte array here? The function is working properly, needs to be tweaked to fail silently, or isn't handling all UTF8 strings properly.

Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.