Serial data receive problem

Aaron Padilla

New Member
Licensed User
Hi.
I am developing a little aplication used for machine monitoring.
an external microcontroller get a data from real world and send it via serial to ppc

The ppc sends a 00h, 02h to wake the microcontroller
then, ppc send a temporized 00, 01 to request data to the microcontroller every 200 ms.
for every request, the microcontroller answers only one byte indicating the value of the measured parameter.

No handshaking, 9600,8,N,1
On comm enabled to handle received data

If the received byte is equal to 26 decimal, the program sends an error message:

unable to cast object of type 'system.int32' to type 'system.array'

I think this is a bug, because it only happens w 26 number, and ONLY on the desktop, once compiled runs fine on the ppc; however it could be a data type or handshaking handle error, I am not an expert on high level programming.
Could you advice?

Regards.

PD. Excuse my spelling, I am from Mexico
 

taximania

Well-Known Member
Licensed User
Longtime User
Some info here:
Reading chr(26) - ASP Free

Try this short program.
The msgbox shows a 'square' character'.
Click on button1, and label1.text shows nothing ???


B4X:
Sub Globals
   'Declare the global variables here.
End Sub

Sub App_Start
   Form1.Show
   Msgbox(Chr(26))
End Sub


Sub Button1_Click
label1.Text=Chr(26)
End Sub


I'll have a play with some of my projects and see if I can get them to raise an error with a '26'.

I don't think it's a bug in B4PPC, it's a Micros$$t problem.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
I've run your program on my desktop connected to one of my laptops by a null modem cable and can confirm the same problem when receiving character decimal 26, but I don't believe it is a Microsoft problem, I think it is within B4ppc.

Your program fails when run within the desktop IDE and when legacy compiled for the desktop. However when optimised compiled on the desktop it works fine. This seems to exonerate both the .NET SerialPort class and the Serial2 library and points to an internal B4ppc problem. To be absolutely sure I renamed Serial2.cs to stop it being merged so guaranteeing that the same library code was used in all cases and the behaviour remained the same.

Erel?
 
Top