Comments (5)
What version of php are you using?
I've tested with version 7.2 and 7.3, so probably the line 68 might to be updated.
You can test the devPath's content by adding the following code temporary:
printf("%s", devPath);
from php-i2c-extension.
The version is as follows.
os: Ubuntu 18.04.5 LTS (Bionic Beaver) / arm64
apache: 2.4.29
php: PHP 7.2.24-0ubuntu0.18.04.6
I inserted printf and checked it, but I could not check it with the following error.
[Sun Sep 27 08: 41: 39.954638 2020] [core: notice] [pid 2493] AH00052: child pid 2494 exit signal Segmentation fault (11)
So, I changed it as follows, but it was the same.
for (int i = 0; i <16; i ++) printf ("% 02X", devPath [i]);
printf ("\ n");
Next, I tried to write the contents to the file, but no error occurred, but the file could not be created (it could not be opened normally).
FILE * fp = fopen ("/tmp/debug.log", "w");
if (fp! = NULL) {
for (int i = 0; i <16; i ++) fprintf (fp, "% 02X", devPath [i]);
fprintf (fp, "\ n");
fclose (fp);
}
from php-i2c-extension.
I additionally confirmed the following.
PHP:
ini_set('display_errors', "On");
$fd = i2c_open("/dev/i2c-0");
i2c.c:
if (fd < 0) {
zend_error(E_WARNING, "open error[%p %p %p %d]", &devPath, devPath, &length, length);
RETURN_BOOL(0);
}
result:
Warning: open error[0x7fddfa7970 0x7f00000000 0x7fddfa796c 10] in /var/www/html/i2ctest.php on line 3
Next, I made the following changes.
i2c.c:
if (fd < 0) {
zend_error(E_WARNING, "open error[%p %p %02X %p %d]", &devPath, devPath, devPath[0], &length, length);
RETURN_BOOL(0);
}
result:
child pid 7628 exit signal Segmentation fault (11)
from php-i2c-extension.
The problem has been resolved. I think it's okay, but please check.
I was worried that the lower 32 bits of devPath was '0' and checked the size of length
sizeof(int)=4 sizeof(size_t)=8
It seems that the lower 32 bits of devPath were overwritten when length was written. I changed i2c.c as follows.
char *devPath;
// int length;
size_t length;
Also, I was worried about the warning at compile time and added the following.
#include <sys/ioctl.h>
from php-i2c-extension.
I've fixed, changing length to size_t and I also initialized it with 0.
from php-i2c-extension.
Related Issues (5)
- Installation problem, unrecognized option --enable-i2c-php HOT 2
- Installation HOT 7
- php 8.1 HOT 1
- Installation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-i2c-extension.