kumandigital Posted June 17, 2009 Share Posted June 17, 2009 Hello.. first i'm sorry for my bad english. i try to access serial port under debian linux box using php direct IO. <?php $fd = dio_open('/dev/ttyS0', O_RDWR | O_NOCTTY | O_NONBLOCK); dio_close($fd); ?> but i get warning like this: Warning: dio_open() [function.dio-open]: cannot open file /dev/ttyS0 with flags 2306 and permissions 0: Permission denied in /var/www/latihan/serial/test.php on line 2 Warning: dio_close() expects parameter 1 to be resource, boolean given in /var/www/latihan/serial/test.php on line 3 can you help me to solve my problem?? thanks before. Quote Link to comment https://forums.phpfreaks.com/topic/162558-access-devttys0-using-php/ Share on other sites More sharing options...
corbin Posted June 17, 2009 Share Posted June 17, 2009 Like the error says, permission is denied. You will either need to change the permissions on /dev/ttyS0, or you will need to run PHP as a different user. If you are running PHP on the command line, you should be able to do: sudo php /path/to/file.php If you go the permissions-changing route, you will want to look into chmod. Quote Link to comment https://forums.phpfreaks.com/topic/162558-access-devttys0-using-php/#findComment-858235 Share on other sites More sharing options...
Maq Posted June 17, 2009 Share Posted June 17, 2009 If you go the permissions-changing route, you will want to look into chmod. Or just change the owner with chown. Quote Link to comment https://forums.phpfreaks.com/topic/162558-access-devttys0-using-php/#findComment-858254 Share on other sites More sharing options...
corbin Posted June 17, 2009 Share Posted June 17, 2009 If you go the permissions-changing route, you will want to look into chmod. Or just change the owner with chown. Yeah, but I wouldn't want to change the owner of the serial port. Perhaps change the group owner and put the user PHP runs under in the group, but I don't like to change the owner from root in cases like that. Maybe I'm just weird haha. Quote Link to comment https://forums.phpfreaks.com/topic/162558-access-devttys0-using-php/#findComment-858272 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.