Git Product home page Git Product logo

Comments (5)

meetanthony avatar meetanthony commented on August 22, 2024

I added an example in the last commit today.
Best regards, Anthony.

from crcphp.

petertest22 avatar petertest22 commented on August 22, 2024

thank you very much for your time and help you are great! I will test it.

from crcphp.

petertest22 avatar petertest22 commented on August 22, 2024

Sorry to disturb you again, the example works fine but i want to use it inside a class and i can't get it working i tried 3 days to sort this, can you help me? I want to pay you. thanks, this is the code, i think must call inside a class? I want to retrieve some bytes (string) from a uploaded bin file and calculate the cs of it. I don't have php expenrience but with some exampe codes it will help me a lot. thanks again!

`<?php

require_once "../utils.php";
include "../crcphp/crc8.php";

class test {

public function read_only(){
return false;
}

public function accept_size($size){
	return $size == 2048;
}



public function get_data($data){

$crc8 = new Crc8();
$algoParams = $CRC_8_;
$algoName = $algoParams->Name;
echo "Name: ".$algoName."<br/>";
$check = $algoParams->Check;
print "Check:  0x".dechex($check)."<br/>";

	
		$test = ((ord($data[0x02]) & 0xFF) << 16)
			+ ((ord($data[0x01]) & 0xFF) << 8)
			+ ((ord($data[0x00]) & 0xFF) );
	$test = intval($test);


	
	$array = array();
	$array['TEST'] =round($test);
	return $array;
}

public function set_test($data, $test2){

if (isset($_POST['swap2'])) {

     $data = swap($data);

} else {

;
}
if($test2 < 0){
$test2 = 0;
} else if ($test2 > 999999){
$test2 = 999999;
}

 for($n = 0x00; $n < 0x80; $n+=16){

		$data[$n+0] = chr(($test2) & 0xFF);
		$data[$n+1] = chr(($test2 >> 8) & 0xFF);
	    $data[$n+2] = chr($test2 >>16 & 0xFF);
		

	}	

if (isset($_POST['swap2'])) {

     $data = swap($data);

} else {
;

}

	return $data;
}

}

?>
`

from crcphp.

meetanthony avatar meetanthony commented on August 22, 2024

It's not good practice, but you can use it as a global variable.

$algoParams = $GLOBALS['CRC_8_'];

from crcphp.

meetanthony avatar meetanthony commented on August 22, 2024

It's not good practice, but you can use it as a global variable.

$algoParams = $GLOBALS['CRC_8_'];

https://stackoverflow.com/questions/1877136/access-global-variable-from-within-a-class

from crcphp.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.