Device Trees: Difference between labels and aliases?

2,461

Aliases are for use by the Linux kernel, but can't be used within the device tree source (DTS) configuration.

Meanwhile, labels can be used in your DTS files to extend or modify the node later.

e.g. You could have a custom DTS file like:

#include "imx6qdl.dtsi"

&gpio2 {
   [your modifications here]
}

Note, again, this would apply to the gpio2 label, not the alias.

Cf. https://elinux.org/Device_Tree_Mysteries#Label_vs_aliases_node_property

Share:
2,461

Related videos on Youtube

gdvander
Author by

gdvander

Updated on September 18, 2022

Comments

  • gdvander
    gdvander over 1 year

    I am trying to create a PHP API for my Android application to use. I am trying to use Volley to handle my HTTP requests. I am returning a JSON string in my PHP script, but Volley only receives a 'status=ok' response.

    Here is the portion using Volley from my Android application.

                //Make json string request
                StringRequest strReq = new StringRequest(Request.Method.GET,
                        url, new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        txtDisplay.setText(response);
                        System.out.println(response);
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error){
                        System.out.println(error);
                }
                });
    

    Here is my PHP script.

    <?php
    require($_SERVER["DOCUMENT_ROOT"] . "/resources/connection.php");
    
    header('Content-type: application/json');
    
    $response["success"] = 1;
    $response["message"] = "Hello World! Database connection has been established!";
    die(json_encode($response));
    ?>
    

    I do not understand why the only response I am getting is 'status=ok'. I am assuming it has to do with the HTTP Response Header Code 200 OK, but I do not know. What am I doing wrong?

    • VinceStyling
      VinceStyling almost 10 years
      what did you get in return, empty's response body? error ? please tell.
    • gdvander
      gdvander almost 10 years
      @VinceStyling I do not get an error. When I print out the response, all I get is 'status=ok' in a string.
    • VinceStyling
      VinceStyling almost 10 years
      Volley won't generate any response like 'status=ok', I suppose that was something wrong in your server-side.
    • gdvander
      gdvander almost 10 years
      @VinceStyling Hmm... Well, when I test the PHP script using Fiddler, the JSON is successfully returned. Do you think the server is returning the 'status=ok' message? Perhaps somewhere in my connection script? I am currently just using MySQL Workbench running locally on my machine for testing.
    • gdvander
      gdvander almost 10 years
      @VinceStyling I figured it out. Thanks for your help!
  • gdvander
    gdvander almost 10 years
    This did not work. I only received 'status=ok' in the response again. This is frustrating. I have no idea why this is not working. Am I not properly passing the JSON from my PHP script? Or is Volley just not grabbing the JSON for some reason?
  • Anderson K
    Anderson K almost 10 years
    @gdvander, see this link Volley
  • gdvander
    gdvander almost 10 years
    I saw this earlier. He wants to be able to POST JSON and only receive a 200 status code back. He doesn't want any JSON returned. I am just trying to get a simple 'Hello, World' JSON response back from my PHP script, but all I am getting is 'status=ok'.
  • Anderson K
    Anderson K almost 10 years
    @gdvander, Have you ever tried using JsonObjectRequest?
  • Anderson K
    Anderson K almost 10 years
    @gdvander, try this in your php: echo json_encode($data);
  • gdvander
    gdvander almost 10 years
    Yes. I have tried JsonObjectRequest, StringRequest, and JsonArrayRequest. The StringRequest is the only one that returns anything. The others give an error because a string is what's being returned.
  • gdvander
    gdvander almost 10 years
    I've tried that too. I know the PHP script is outputting JSON. I am using Fiddler to test it.
  • Anderson K
    Anderson K almost 10 years
    @gdvander,Send and Receive JSON between Android and PHP Web Service, see the end of the post Points of Interest
  • gdvander
    gdvander almost 10 years
    In that scenario, he is posting JSON to his PHP API and is trying to read it in the PHP script. Thanks for your help, but I think I am going to take a break now. I will come back to it later. The issue must be bigger than I had expected. Thanks!
  • Anderson K
    Anderson K almost 10 years
    @gdvander, For nothing friend, I confess that php is not half strong, I use java side serves, and for communication between a server is an app where, I use a service like Restfull Jersey, and you are thinking about the future do something beyond helloworld and want to use php, I suggest a framework like PhPSlim!
  • gdvander
    gdvander almost 10 years
    Thank you for your help! I will take PHPSlim into consideration!
  • Noah
    Noah almost 10 years
    For reference: No machine can communication with another machine's "localhost". localhost ALWAYS refers to the device itself
  • gdvander
    gdvander almost 10 years
    Thanks, I know that now! I'm new to web and networking stuff.
  • happyMOOyear
    happyMOOyear over 8 years
    I still have not found a good answer to my question so thanks for your input. In case of the label gpio0 I think it is clear that I refer to gpio1@0209c000. But which gpio am I refereing to when I use the label gpio1? gpio1@0209c000 or gpio2@020a0000?
  • Daniel
    Daniel over 8 years
    if you use gpio1, that is the alias. if you wish to access gpio1@0209c000 you must either use the gpio0 alias, or the full gpio1@0209c000 label.