c – How to check data has been received correctly with CRC – much confusion here

I am trying to process some serial data (sent over UART). Its coming from a radio controlled receiver, is 27 bytes long. The last 2 bytes of this are a 16bit CRC check according to the spec.

The checksum is derived from the preceding 25 bytes

Along with the protocol there is this information on the checksum calculation:

 u16 CRC16(u16 crc, u8 value)
 {
     u8 i;
     crc = crc ^ (s16)value<<8;
     for(i = 0; i < 8; i++)
     {
         if(crc & 0x8000)
             crc = crc << 1^0x1021;
         else
             crc = crc << 1;
     }
     return crc;
 }

I have had to do a little ‘translation’ of this, as I am using an STM32 microcontroller, and the variables need to be declared a little different (uint16_t instead of u16 for example).

That said I think I have got completely the wrong end of the stick anyway…..

The code above appears to ‘only’ process a single byte of data, passed to the function in variable ‘value’

It appears to also want a 16bit integer named ‘crc’ passed to it, which is where the confusion started……

I have the 27 byte packet of data. I have converted the last 2 bytes into the 16 bit checksum and have made sure that I have the endianness of this correct (the message is big endian, the stm32 is little endian, so you cant do a memcpy, you need to do a bit of bit shifting).

But how do I now get an answer as to whether the preceding 25 bytes of data have been received correctly.

Any help gratefully received. I’ve googled and read and just got myself more confused….

Many thanks

James

sharepoint designer – SPDESIGN.EXE Application error The application was unable to start correctly (0xc000007b )

Sharepoint designer 2013 installed successfully on my PC without prompting any error.
After installation while opening it’s showing error.

SPDESIGN.EXE Application error The application was unable to start correctly (0xc000007b ).

I have preinstalled frameworks

Microsoft.net compact framework 2.0 SP2

Microsoft.net compact framework 3.5

Microsoft.net compact framework 4.5.1 Multi targeting pack

Microsoft.net compact framework 4.6.1 SDK

Microsoft.net compact framework 4.6.1 targeting pack

Do i need to install any prerequisite before SP designer installation?

any clue, please.

object oriented – PHP Building customer class with extends, am I doing it correctly?

I am trying to build my own customer class. Customer data is separated in 4 MySql tables. I am not sure if this is idiotic or not yet.

The tables are securities, customer, address and contact. The 4 tables are related by Customer_ID

I created securities class and I created a customer class extending on securities class.

<?php
//create user object
class securities{
    private $con;
    private $table = "securities";

    //properties required
    public $Security_ID;
    public $Customer_ID;
    public $Username;
    public $password;
    public $PSW_Hint;
    public $Verification;
    public $reg_date;

    //constructor
    public function __construct($db){
      $this->con = $db;
    }
    //check if username exists
    function userNameExists(){

      //query to check if username exists
      $query = "SELECT  Security_ID, Customer_ID, Username, PSW, PSW_Hint, Verification
                FROM " . $this->table .
                " WHERE Username = ?,
                LIMIT 0,1";
      //prepare query
      $stmt = $this->con->prepare($query);
      //sanitize
      $this->username=htmlspecialchars(strip_tags($this->username));
      //bind given username
      $stmt->bindParam(1, $this->username);
      //execute the queery
      $stmt->execute();
      //count returning number of rows
      $num=$stmt->rowCount();

      //if username exists
      if($num>0){

          $row=$stmt->fetch(PDO::FETCH_ASSOC);

          $this->Security_ID = $row('Security_ID');
          $this->Customer_ID = $row('Customer_ID');
          $this->Username = $row('Username');
          $this->password = $row('PSW');
          $this->PSW_Hint = $row('PSW_Hint');
          $this->Verification = $row('Verification');
          //return true if user exists
          return true;
      }
      //return false if username does not exists
      return false;
    }

  }

  class customer extends securities {

    private $table = "customer";

    //properties required
    public $firstname;
    public $lastname;
    public $fullname;
    public $Gender;
    public $Birthdate;
    public $Verification;
    public $reg_date;

    //constructor
    public function __construct($db){
      $this->con = $db;
    }

    public customerExists(){

      //query to check if username exists
      $query = "SELECT  Customer_ID, firstname, lastname, fullname, Gender, Birthdate, Verification
                FROM " . $this->table .
                " WHERE Customer_ID = ?
                LIMIT 0,1";
      //prepare query
      $stmt = $this->con->prepare($query);
      //sanitize
      $this->Customer_ID=htmlspecialchars(strip_tags($this->Customer_ID));
      //bind given username
      $stmt->bindParam(1, $this->Customer_ID);
      //execute the queery
      $stmt->execute();
      //count returning number of rows
      $num=$stmt->rowCount();

      if($num>0){

          $row=$stmt->fetch(PDO::FETCH_ASSOC);

          $this->Customer_ID = $row('Customer_ID');
          $this->firstname = $row('firstname');
          $this->lastname = $row('lastname');
          $this->fullname = $row('firstname' + 'lastname');
          $this->Gender = $row('Gender');
          $this->Birthdate = $row('Birthdate');
          $this->Verification = $row('Verification');
          //return true if user exists
          return true;
      }
      //return false if username does not exists
      return false;
    }
  }

?>

What I am wondering right now is:

  • Should I abandon the thought of spreading customer data over 4 different tables and put all customer data into 1 table?
  • How do I refer in my customer class to the Customer_ID in securities class
  • Should I build 2 more extend classes for the other tables or changed the query in the Customer class by using LEFT JOINING the other 2 tables?

c++ – How to correctly generate tile map with atlas in cocos2d-x (4.0) without TMX file?

Good afternoon!

Can someone give me advice, what is the proper way to generate TileMap?
I know about TiledMapTileLayer in LibGdx. With that tool i could set tile map cell by cell, something like this:

TiledMapTileLayer.Cell cell = new TiledMapTileLayer.Cell();
cell.setTile(new StaticTiledMapTile(splitTiles((int)cellCoordinates.x)((int)cellCoordinates.y)));
cell.setFlipVertically(tileInfList.get(i).isFlipVertical());
cell.setFlipHorizontally(tileInfList.get(i).isFlipHorizontal());

So algorithm was like this:

  1. I parsed my “custom” xml file with map properties (not TMX), such as position of tile in image atlas and position in game world.
  2. I created new TiledMap() and TiledMapTileLayer.
  3. Added cells to a layer. Than render layer.

But can Cocos2d work with tiles in such a way? Or i should create individual sprite for this purpose (like cells in LibGdx)?
What is the best way to positioning and create map if you have an atlas and xml file with map properties?

<TileMap defaultScale="1.0" image="img/love_island_atlas.png" maxScale="2.0" minScale="0.25" tileBorderSize="2" tileHeight="100" tileMapHeight="2700" tileMapWidth="3400" tileWidth="100" tilesPerAtlasColumn="4" tilesPerAtlasRow="4">
  <items>
    <list>
      <Tile flipHorizontal="false" flipVertical="false" height="100" index="1" width="100" x="480" y="-1136"></Tile>
      <Tile flipHorizontal="false" flipVertical="false" height="100" index="10" width="100" x="2080" y="464"></Tile>
      <Tile flipHorizontal="false" flipVertical="false" height="100" index="1" width="100" x="3780" y="-1036"></Tile>
      ....
    </list>
</items>

Thank you guys!

seo – How to correctly select ccTLD domain for same speaking native language countries?

We know that South America’s native-speaking language Portuguese (Brazil) and Spanish (Spain, Argentina, Colombia, Chile, Peru, Uruguay, etc.). My keyword targeting audience to South American users.

I want to take a second-level domain example.com.es (Spain) that will run with a micro-niche blog website and will need to target both country + language.

Now, Can I rank South American’s Spanish language country with example.com.es?

Can I get any SEO facilities for Spanish 2 letter language code – es

and for Portuguese language example.com.es/pt

that’s a good or bad strategy?

How to set the screen size in Ubuntu to correctly fit your monitor so that there are no scroll bars on the bottom & right & no windows go out of view?

Pretty much what’s there in the question.
Following are the specs.
OS: Ubuntu 20.04 LTS
Monitor specs : 15.6"
Running on Oracle Virtual box

Thank you

signature – How to verify if a transaction is signed correctly?

Pubkey script alone is not enough to verify a transaction, you’ll need:

  1. Pubkey script, to evaluate the scripts
  2. Amount, in order to check if the sum of inputs is bigger than or equal to sum of outputs
  3. Index (in TxOut list) and tx hash of the transaction being spent
  4. Block height so that you can set the consensus rules

After gathering all the above (should be found in the node’s UTXO database) you can start evaluating if the provided script is valid which isn’t limited to signature verification but running/evaluating the script that includes checking correctness of the script, OP codes, OP count, script size,…
A lot of the verification can be found in validation.cpp file.
This is also how I do it in Bitcoin.Net library.

signature – How to verify if a transaction is correctly signed?

Given an arbitrary signed raw transaction, how can we easily verify if all inputs are correctly signed (assuming all inputs are existent/unspent and the fee is higher than zero)? Bitcoin core’s RPC command testmempoolaccept will check if all inputs are available to be spent in the mempool/blockchain so it’s impossible to test transactions that have parents not yet broadcasted.

I am aware that for this kind of check, the scriptPubKeys of all inputs needs to be known and therefore only the signed raw transaction by itself is not enough for this kind of check. Still, the scriptPubKeys could be passed to the transaction instance or verify method. I was looking for some nice way to do this in python/javascript but was surprised how difficult this task is:

networking – How do I configure my Linux eth interfaces correctly?

This subject drives me crazy. No matter what instructions I follow on the Internet. It only generates problems. I want to configure my eth0 interface for IPv4 and IPv6 for a static IP on Debian Buster.

nano /etc/network/interfaces

Whats inside:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address xxx.xxx.xxx.xxx     # my Public-IP IPv4
        netmask 255.255.252.0       # my Netmask
        broadcast xxx.xxx.xx.xxx    # my Broadcast
        gateway xxx.xxx.xxx.xxx     # my Internet Gateway
        dns-nameservers 0.0.0.0 9.9.9.9  # Using local DNS Resolver, Quad9 as Backup

iface eth0 inet6 static
        address 2a03:xxxx           # my Public-IP IPv4
        netmask 64                  # my Netmask
        gateway fe80::1             # my Internet Gateway
        dns-nameservers ::1 2620:fe::fe   # Using local DNS Resolver, Quad9 as Backup

Performing systemctl restart networking.services results in:

$ systemd[1]: Starting Raise network interfaces...
$ ifup[12031]: Waiting for DAD... Done
$ ifup[12031]: RTNETLINK answers: File exists
$ ifup[12031]: ifup: failed to bring up eth0
$ networking.service: Main process exited, code=exited, status=1/FAILURE
$ systemd[1]: networking.service: Failed with result 'exit-code'.
$ systemd[1]: Failed to start Raise network interfaces.

Any help is appreachiated.

Do browsers correctly interpret rel tags in links created by PHP’s htmlspecialchars()?

The logic of PHP’s htmlspecialchars() is such that, according to its manual, “Certain characters have special significance in HTML, and should be represented by HTML entities if they are to preserve their meanings.”

And so, something like this

<?php
$str = "This is some <b>bold</b> text.";
echo htmlspecialchars($str);
?>

shows on the browser as

This is some <b>bold</b> text.

but in the View Source output as

<!DOCTYPE html>
<html>
<body>
This is some &lt;b&gt;bold&lt;/b&gt; text.
</body>
</html>

My question is:

Do browsers understand link rel tags (e.g. rel="noopener") when created this way? In the View Source, I see something like

&lt;a href=&quot;https://www.example.com&quot; rel=&quot;noopener&quot; target=&quot;_blank&quot;&gt;Page&lt;/a&gt;:&lt;br&gt;&lt;br&gt;

whereas on the browser the link appears normally and the url opens in a new tab, as expected. If the browser can correctly interpret &quot; target=&quot;_blank&quot; as target="_blank", is it a fair assumption that it also understands rel=&quot;noopener&quot; as rel="noopener"?

Because this has obvious security implications.