mercredi 29 juin 2016

Trying to run a cross-compiled executable on target device fails with: No such file or directory

I've got caught in the not-so-sunny world of cross-compilation.

I'm trying to compile a simple hello world application for my BeagleBone Black (which runs a TI Cortex-A8 processor).

First of all, I compiled and ran successfully the hello world application on x86 with gcc

Then I changed my compilation settings to the following:

arm-linux-gnueabi-gcc -c -O0 -g3 -Wall main.c -o bin/obj/main.o
arm-linux-gnueabi-gcc bin/obj/main.o -o bin/hello_world

I transferred the file via SCP to the BeagleBone, and set executable permissions with chmod +x hello_world

Upon running it (./hello_world), my only response is:

-bash: ./hello_world: No such file or directory

The output of file matches that of /sbin/init as I would expect:

$ file hello_world
hello_world: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0x24b659b7a41fe043a6f4649d4ebfb5e692ebf0c7, not stripped
$ file /sbin/init
/sbin/init: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xd21f6957ec031a27d567b3d5e6aa14b9e0c30c37, stripped

The result of ldd is:

$ ldd hello_world
    not a dynamic executable

I tried adding a suitable platform and CPU type, changing my compilation to:

arm-linux-gnueabi-gcc -c -O0 -g3 -Wall -march=armv7-a -mtune=cortex-a8  main.c -o bin/obj/main.o
arm-linux-gnueabi-gcc bin/obj/main.o -o bin/hello_world

This initially started giving me a new error: Text file busy, but I have since been unable to get that error back again as it now returns No such file or directory. I'm guessing that particular attempt was just a bad transfer or something.

illegal string offset 'name' when working with password fields laravel 4.2

hi i have this custom validation i declared in my start->global.php what it does is compare the password inside the database and the entered 'current password' here is the code

Validator::extend('chkcpass', function($attribute, $value, $parameters)
{
   $getAcc = DB::table('nsa_systemusers')
           ->where('sid' , '=' , $parameters)
           ->get();

 foreach ($getAcc as $key => $gcp)
 $ucp = $gcp->password;

 $sptkey  = md5('3982f3a0c86f272633fc7105040a83c8');
 $decPass = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $sptkey, base64_decode($ucp), MCRYPT_MODE_ECB));

 if($value != $decPass)
 {
      return false;
 }
 else
 {
      return true;
 }

});

in my controller im calling it like this

$uid = Session::get('sid');
    $rules = array(
        'ecp'   => 'required|min:8|max:255|chkcpass:'.$uid,
        'np'    => 'required',
        'rnp'   => 'required',
    );

and in my view here is the form

{{ Form::open(array('url' => 'usrchangepassword')) }}
                <div class="row">
                    <div class="input-field col s10">
                        {{ Form::label('pass', 'Enter Current Password') }} 
                        {{ Form::password('ecp' , array('class' => 'form-control')) }}
                    </div>
                </div>
                <div class="row">
                    <div class="input-field col s10">
                        {{ Form::label('pass', 'Enter New Password') }} 
                        {{ Form::password('np' , array('class' => 'form-control ')) }}
                    </div>
                </div>
                <div class="row">
                    <div class="input-field col s10">
                        {{ Form::label('pass', 'Re-type New Password') }} 
                        {{ Form::password('rnp' , array('class' => 'form-control ')) }}
                    </div> 
                </div>
                @if ($errors->any())
                    <div class='err'>
                        <ul>
                            {{ implode('', $errors->all('<strong><li class="ermsg">:message</li></strong>')) }} 
                        </ul> 
                    </div>
                @endif
                <br>
                {{ Form::submit('save', array('class' => 'btn btn-primary savebtn')) }}
            {{ Form::close() }}

but im getting an error saying i have an error in my view blade about

Illegal string offset 'name' 

any ideas what i am doing wrong? thanks so much in advance!

mardi 28 juin 2016

How should I include variable defined with extern in c file

I am having trouble compiling the demonstration code for the STM32F4-Discovery using the arm-none-eabi toolchain. The error is occuring in linking and this is the [first] error I'm receiving.

template/obj/stm32f4xx_it.o: In function `OTG_FS_IRQHandler':
template/src/stm32f4xx_it.c:192: undefined reference to `hpcd'

I've been trying to figure this out on and off for several months so I've created this github repository to track the project. The variable hpcd is defined in template/src/usbd_conf.c. My knowledge of C/C++ is unfortunately full of holes, so I'm hoping someone may help me both narrow down the problem and the suggest the proper way to fix it.

I have two questions.

  1. hpcd is included in the file usbd_conf.c. It is used in many files, but none of these files actually include usbd_conf.c, only usbd_conf.h. The question is, by only including the header, can a file which declares a variable as extern PCD_HandleTypeDef hpcd; use the variable without specifically including the .c file?
  2. Assuming the answer to question 1 is yes, why is it the function OTG_FS_IRQHandler isn't finding hpcd? The chain of includes from stm32f4xx_it is main.h -> usbd_core.h -> usbd_conf.h.

I'm assuming the answer to question 1 is yes because this is the demonstration code I believe was running on the board when I purchased it. I can only assume the poblem is with the way I'm building it. Would anyone be willing to help me troubleshoot this problem? I would be happy to provide more details if relevant or to better structure this question, but I'm trying to avoid posting a full USB stack in my question. Thank you.

PHP to create XML File not generating properly

I am trying to add another element to to my xml file. Here is what it generates right now.

flipsnack>
<title>Book 1</title>
<date>6-6-2016</date>
<link>google.com</link>
<embed>this is hetml code</embed>
<order>1</order>
<show>1</show>
<flipsnack>
<title/>
<link>hotmail.com</link>
<embed>html code all the way</embed>
<order>2</order>
<postdate/>
<show>1</show>
</flipsnack>
</flipsnack>

Here is what i think it should be....

<?xml version="1.0" encoding="UTF-8"?>
<flipsnack>

    <book>
    <title>Book 1</title>
    <date>6-6-2016</date>
    <link>google.com</link>
    <embed>this is hetml code</embed>
    <order>1</order>
    <show>1</show>
    </book>

    <book>
    <title>Book 1</title>
    <date>6-6-2016</date>
    <link>google.com</link>
    <embed>this is hetml code</embed>
    <order>1</order>
    <show>1</show>
    </book>
</flipsnack>

Here is my php code:

$title=$_POST["post"];
$date=$_POST["date"];
$link=$_POST["link"];
$html=$_POST["html"];
$order=$_POST["order"];
$show=$_POST["show"];

$xml = simplexml_load_file("db.xml");
$sxe = new SimpleXMLElement($xml->asXML());
$newItem = $sxe->addChild("flipsnack");
$newItem->addChild("title", $title);
$newItem->addChild("link", $link);
$newItem->addChild("embed", $html);
$newItem->addChild("order", $order);
$newItem->addChild("postdate", $postdate);
$newItem->addChild("show", $show);
$sxe->asXML("db.xml"); 

I dont quite under stand how i get from what its doing now to what i want it to do? Could anyone give me some direction?

Laravel multiple forms with a only one submit button?

I have a form that can edit multiple areas in multiple tables, but it does not work unless I have a submit button within each form , is there any way to do this with one submit button?

    {!!Form::model($pregunta,['route'=>['seleccion.update',$pregunta->id],'method'=>'PUT','files' => true])!!}
    {!!Form::label('categoria','Categoria: ')!!}
      {!!Form::select('categorias_id', $categoria,null,['id'=>'categoriaSelSimple','class'=>'form-control',
                                            'placeholder'=>'Seleccione una opcion..','required'])!!}<br>
      {!!Form::label('subcategoria','Sub-categoria: ')!!}
      {!!Form::select('sub_categorias_id', $subcategoria,null,['id'=>'subcategoriaSelSimple','class'=>'form-control',
                                            'placeholder'=>'Seleccione una opcion..','required'])!!}<br>
    @foreach($opcion as $key => $value)
        {!!Form::model($value,['route'=>['opciones.update',$value->id],'method'=>'PUT'])!!}
        <div class="form-group option-container">
            <div class="input-group ">
              @if($value->correcto == 1)
                <span class="input-group-addon">
                  {!!Form::select('correcto[]', ['0' => 'Incorrecto','1' => 'Correcto'])!!}
                </span>
              @else
                <span class="input-group-addon">
                  {!!Form::select('correcto[]', ['1' => 'Correcto','0' => 'Incorrecto'])!!}
                </span>
              @endif
                {!!Form::text('opcion[]',$value->opcion,['class'=>'form-control']) !!}
                {{-- {!!Form::text('opcion[]',null,['class'=>'form-control', 'placeholder'=>'Ingresa una opcion..'])!!} --}}
              <span opcion-id="{{$value->id}}" class="input-group-btn">
                  <button class="btn btn-outline btn-danger btn-remove" type="button">X</button>
              </span>
            </div>
        </div>
        {{Form::close()}}
      @endforeach
                        <button type="button" class="btn btn-outline btn-success btn-lg btn-block btn-add-more-options">Agregar opción</button>
                        <h1 class="page-header"></h1>
                        {!!Form::submit('Actualizar',['class'=>'btn btn-outline btn-primary'])!!}

        </div>

    <!-- /.col-lg-8 -->
    <!-- /.col-lg-4 -->
</div>
{!!Form::close()!!}

I have multiple forms, one main and the others added through a foreach (how many depends of the table ), so i need to update these fields generated by the foreach but it doesn't work because i dont have a submit button for each form, how i can do this??

Sending data SAP Fiori launchpad webapp/SAPUI5 webapp from client side javascript

This is a general question I have as I am exploring the world of automating some tasks in my workplace.

We have a portal/launchpad environment on our businesses website which has apps shown as tiles.

One of these apps when opened has a homepage that has a bunch of search fields and selectors to interface with (I assume) SAP data.

Ultimately my goal is to be able to send a number to a specific search field on a client-side local webapp (just plain old HTML/jquery stuff) and execute a search for that number in the sapui webapp.

I am getting to an competent level with javascript/HTML/CSS but am completely lost as to where to start with this type of issue as the MVC stuff is completely alien to me.

All my experience has been in creating completely client-side web apps with mostly interface with a local MS Access database.

Is what I am suggesting even possible?

So far I can open the homepage by executing the following code that someone else in the organization used:

window.open('https://fiori.mycompany.com/sap/bc/ui5_ui5/sap/z_cs_ch/index.html

Is it possible to add some form of string after a ?.... at the end of the url?

Again I am completely new to this and looking at the development guides in sapui website isn't shedding any light on it either. Possibly because I don't really know exactly what I am looking for!

Any help /guidance is greatly appreciated.

EDIT: After comments below I can see the request sent to server is in the following format:

Request GET /sap/opu/odata/sap/someotherlocation/SearchTerm('<variable to search for>')?$format=json HTTP/1.1

Am I right in thinking I could potentially send an ajax request to do something similar? If so, how do I go about it?

Thanks again

PHPMailer multiple sending mail

Im using pop3 php mailler and ajax. There is no problem for sending mail but when I press sent mail button it incease number of mails. So whats the problem

my ajax code :

$("button").click(function(e){
 $('.alert').slideUp(100);
  e.preventDefault();
  var dataArray = $("form").serialize();
  $.ajax({
   type: "POST",
   url: "include/login.php",
   dataType: "json",
   data: dataArray,
   success: function (data) {
    if(data.result == "true"){
     $('.alert').removeClass('alert-danger').addClass('alert-success').slideDown(200);
      $('.alert strong').html("hello "+data.name);
        setTimeout(function(){ 
        window.location.replace("<?php if(isset($_SERVER['HTTP_REFERER'])) { echo "$_SERVER[HTTP_REFERER]";}else{echo "index.php";} ?>"); 
      }, 1200);
     }else if(data.result == "false"){
     $('.alert').removeClass('alert-success').addClass('alert-danger').slideDown(200);
     $('.alert strong').html(data.name);
     }else if(data.result == "warning"){
         $('.alert').removeClass('alert-warning').addClass('alert-danger').slideDown(200);
         $('.alert strong').html(data.name);
         /// send mail button click 
             $('body').on('click','#activation',function(e){
              e.preventDefault();
              $.ajax({
                  beforeSend:function(){
                       $('.alert strong').html("sending mail..");    
                  },
                  url:"include/activation_mail.php",
                  type:"post",
                  data:{u_id:data.userid,u_pass:data.u_pass},
                  success:function(msj){
                     $('.alert').removeClass('alert-danger').addClass('alert-success').slideDown(200);
                     setTimeout(function(){
                     $('.alert strong').html(msj);    
                  },1000);
                 },
                });
              });
             }
            },
          });
      });

mailing php :

$sql = "UPDATE users SET u_activation_code = '$activation_code' WHERE u_id = '$u_id'";
    $query = mysqli_query($con,$sql);
    if($query){
        $sql="SELECT * FROM users WHERE u_id='$u_id'";
        $query = mysqli_query($con,$sql);
        $row = mysqli_fetch_row($query);
        $id = $row[0];
        $name = $row[1];
        $surname = $row[2];
        $fullname = "$row[1] $row[2]";
        $username = $row[5];
        $email = $row[6];
        $icerik = "aktivasyon maili <a href=''>activation</a>";

        $mail = new PHPMailer();
        $mail->CharSet='utf-8';
        $mail->setFrom('fragman@aktivasyon', 'Aktivasyon');
        $mail->addReplyTo('mymail@gmail.com', 'activation');
        $mail->addAddress($email,$fullname);
        $mail->Subject = 'activation link';
        $mail->AltBody = 'This is a plain-text message body';
        $mail->Body = "click active <a href=''>clicked</a> ";


        //send the message, check for errors
        if (!$mail->send()) {
            echo "error sending: " . $mail->ErrorInfo;
        } else {
            echo "send mail";
        }
    }else{
        echo "error query";
    }

where is problem ?