B4J Question Inconvertible types

Discussion in 'B4J Questions' started by HARRY, Mar 17, 2015.

  1. HARRY

    HARRY Active Member Licensed User

    Hi,

    When compiling my first B4j program, I get following message:

    B4J version 2.80
    Parsing code. 0.00
    Compiling code. 0.03
    Compiling debugger engine code. 0.64
    Compiling generated Java code. Error
    B4J line: 82
    registrationmsg = s
    javac 1.7.0_45
    src\b4j\example\main.java:242: error: inconvertible types
    _registrationmsg = (b4j.example.main._registrationmsgstruct)(_s);
    ^
    required: _registrationmsgstruct
    found: String
    1 error


    I wonder what 'B4j line : 82' means, certainly not the line number of my source code. That reads ' i=23'.

    B4j-Bridge is connected.

    More important what causes this error message? Should I register something?

    Harry
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    What are the types of registrationmsg and s?
     
  3. HARRY

    HARRY Active Member Licensed User

    Hi Erel,

    I see the problem, but not yet the solution. Yesterday I was sleepy and confused by the line number. I thought 'registration', what registration? Registrationmsg is a structure I declared myself; s is a String.
    Part of the code is as follows:

    Type registrationmsgstruct(length As Long,src As Byte, ack As Byte, eleccountday As Long, eleccountnight As Long, elecconsumption As Long, gasdatetime(13) As Char, gascount As Long, msgnr As Byte)
    Dim registrationmsg As registrationmsgstruct


    Sub AStream_NewData (Buffer() As Byte)
    Dim s As String = BytesToString(Buffer, 0, Buffer.Length, "UTF8")

    registrationmsg = s This is the line which gives the problem, I assume. The buffer should be copied to the structure as a serie of bytes. The length is exactly the same.

    How can I do that? A kind of memcpy would be usefull. On internet I find something like that, but then I need the Class System, which I cannot find. Also a complete sample would be nice.

    Harry
     
    Last edited: Mar 18, 2015
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. HARRY

    HARRY Active Member Licensed User

    Erel,

    Unfortunately I cannot use sending objects as the 'other' side is an Arduino computer. I will look for another solution.

    Harry
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice