Group Details Private

Global Moderators

Forum wide moderators

  • RE: Control PWM hardware from C

    @nsmith It's a script. /usr/bin/onion

    posted in Omega Talk
  • RE: Custom Image Build Error

    @Antony The key error is : ``/bin/sh: 1: svn: not found`

    SVN is the Subversion client, mpg-streamer must use this in its make file to pull source code from a Subversion repository. You'll need to install the Subversion client on the machine yu are executing the build. On ubuntu you would use the command:

    sudo apt install subversion

    posted in Omega Talk
  • RE: Location of .bin file Omega2pro

    @Antony The bin file extension indicates the file is binary, that's all. The file does not exist on the device itself it is simply used to write the contained firmware image onto the device's "memory".

    If yu wish to download a copy of the firmware image from the Onion firmware repository you can find them here:

    http://repo.onioniot.com/omega2/images/

    The latest version appears to be omega2pro-v0.3.3-b256.bin

    posted in Omega Talk
  • RE: Control PWM hardware from C

    @nsmith Some sample code:

    #include "include/motor.hpp"
    #include "include/gpiomux.h"
    #include "include/uciutils.h"
    #include "include/common.hpp"
    
    #include <string>
    #include <math.h> 
    #include <syslog.h>
    
    
    Motor::Motor(char *uci_path, int max_move_time = 0){
        // null the callbacks so we can check if they have been set 
        _moving_call_back = NULL;
        _stop_call_back = NULL;
        _forward_call_back = NULL;
        _reverse_call_back = NULL;
        _max_move_time = max_move_time;
    
        init(uci_path);
    }
    
    int Motor::init(char *uci_path){
        _pwm_channel = get_uci_path_int(uci_path, UCI_OPTION_MOTOR_PWM, STD_MOTOR_PWM_CHANNEL);
        _freq = get_uci_path_int(uci_path, UCI_OPTION_MOTOR_FREQ, STD_MOTOR_FREQ);
        _forward_duty = get_uci_path_int(uci_path, UCI_OPTION_MOTOR_FORWARD_DUTY, STD_FORWARD_DUTY);
        _reverse_duty = get_uci_path_int(uci_path, UCI_OPTION_MOTOR_REVERSE_DUTY, STD_REVERSE_DUTY);
        _stop = get_uci_path_int(uci_path, UCI_OPTION_MOTOR_STOP_DUTY, STD_MOTOR_STOP_DUTY);
        if (get_uci_path_int(uci_path, OPTION_MOTOR_DISABLED, 0)==1){
            _config_disabled = true;
            _disabled = true;
            syslog(LOG_NOTICE,"%s is disabled", uci_path);
        }
        else { // some pins need to be set to GPIO mode if they are muxed.
            gpiomux_mmap_open();
            std::string pwm = "pwm" + std::to_string(_pwm_channel);
            int mux_result = gpiomux_set(const_cast<char*>(pwm.c_str()), "pwm");
            syslog(LOG_DEBUG, "GPIO Mux returned %d", mux_result);
            gpiomux_mmap_close();
            openPwm();
        }    
    }
    
    
    int Motor::stop(){
        if (isDisabled()==true)
            return EXIT_FAILURE;
        
        _is_moving = false;
        if (_stop_call_back!=NULL)
            _stop_call_back(_is_moving);
        setPwm(_stop);
        syslog(LOG_DEBUG,"Motor Stop");
    }
    
    int Motor::forward(bool autostop = false){
    
        if (isDisabled()==true)
            return EXIT_FAILURE;
        _is_moving = true;
        if (_forward_call_back!=NULL)
            _forward_call_back(_is_moving);
        setPwm(_forward_duty);
        if(_max_move_time > 0 && autostop == true) {
            sleep(_max_move_time);
            stop();
        }
    }
    
    int Motor::reverse(bool autostop = false){
        if (isDisabled()==true)
            return EXIT_FAILURE;
        //syslog(LOG_DEBUG,"Motor Reverse");
        _is_moving = true;
        if (_reverse_call_back!=NULL)
            _reverse_call_back(_is_moving);
        setPwm(_reverse_duty);
        if(_max_move_time > 0 && autostop == true) {
            sleep(_max_move_time);
            stop();
        }
    }
    
    int Motor::setPwm(int duty){
    
        if (isDisabled()==true)
            return EXIT_FAILURE;
        
        float period = ( 1.0 / _freq ) * 1000000000;
        float pulseWidth = (period * duty) / 100;
        
        int iPeriod = round(period);
        int iPulseWidth = round(pulseWidth);
    
        std::string periodFileName =  std::string(PWM_MAIN_DIRECTORY) + std::string("pwm") + std::to_string(_pwm_channel) + std::string("/period");
        std::string dutyFileName =  std::string(PWM_MAIN_DIRECTORY) + std::string("pwm") + std::to_string(_pwm_channel) + std::string("/duty_cycle");
        std::string enableFileName =  std::string(PWM_MAIN_DIRECTORY) + std::string("pwm") + std::to_string(_pwm_channel) + std::string("/enable");
    
        FILE *fp = fopen(periodFileName.c_str(), "w");
    
        if (fp == NULL) 
            return EXIT_FAILURE;
    
        fprintf(fp, "%d", iPeriod);
        fclose(fp);
        
        fp = fopen(dutyFileName.c_str(), "w");
    
        if (fp == NULL) 
            return EXIT_FAILURE;
    
        fprintf(fp, "%d", iPulseWidth);
        fclose(fp);
    
        fp = fopen(enableFileName.c_str(), "w");
    
        if (fp == NULL) 
            return EXIT_FAILURE;
    
        fprintf(fp, "%d", 1);
        fclose(fp);
        
    }
    
    
    Motor::~Motor(){
        closePwm();
    }
    
    
    int Motor::openPwm(){
    
        FILE *fp = fopen(PWM_EXPORT_FILE, "w");
        if (fp == NULL) 
            return EXIT_FAILURE;
    
        fprintf(fp, "%d", _pwm_channel);
        fclose(fp);
        
    }
    
    
    int Motor::closePwm(){
    
        stop();
        
        FILE *fp = fopen(PWM_UNEXPORT_FILE, "w");
    
        if (fp == NULL) 
            return EXIT_FAILURE;
    
        fprintf(fp, "%d", _pwm_channel);
        fclose(fp);
        
    }
    
    void Motor::enable(){
    
        // in case we disabled the motor for emergency stop, 
        // check we don't enable it if the configuration
        // says it disabled.
        if (_config_disabled == true)
            return;
    
        syslog(LOG_DEBUG, "Motor Enabled");
        _disabled = false;
    }
    
    void Motor::disable(){
        if (_disabled==false)
            syslog(LOG_DEBUG, "Motor Disabled");
    
        if (_is_moving == true)
            stop();
        _disabled = true; _is_moving = false;
    }
    
    posted in Omega Talk
  • RE: Control PWM hardware from C

    @nsmith The easiest way to control PWM is using sysfs, if you look at the docs you can see the process is simpy to write to the control files.

    https://docs.onion.io/omega2-docs/generating-pwm-signals.html

    posted in Omega Talk
  • RE: Switching from HTTP to HTTPS.

    @Anushka2033 We can see that the index file is being downloaded so the issue is the script in the file is failing. I don't use OnionOS app for a long time now so I can only go by my assumptions. I suspect the issue is the script is failing to load the resources due to the certificate error/warning. My first step would be to delete /etc/uhttpd.key and /etc/uhttpd.crt. Then run the commands:

    uci set uhttpd.defaults.commonname='localhost'
    uci commit uhttpd
    service uhttpd restart

    This should regenerate the certificate files with the correct CN, now see if you can access the OnionOS pages using https.

    posted in Omega Talk
  • RE: Switching from HTTP to HTTPS.

    @Anushka2033 Please post the output of the command uci show uhttp

    posted in Omega Talk
  • RE: Step-by-Step Video Instructions for Mobile Network File Server (Cloud)?

    @Amalee you are receiving permission denied errors because you are trying to execute configuration files. The first command you execute is "/etc/config/samba" this a uci configuration file, you can see the content using the command cat /etc/config/samba

    Next you try to execute /etc/samba/smb/conf/conf/template which again will be a configuration file used by samba, although I think your path is wrong. Similarly /etc/config/firewall is the uci configuration file for the firewall, not a file you can execute.

    Take a look at this link SAMBA Documentation which explains how to run and configure SAMBA.

    posted in Projects
  • RE: oupgrade returns "Failed to parse message data" even after updating via opkg

    @bzhu95 please post the output of the commands:

    uci show | grep opkg

    posted in Omega Talk
  • RE: Omega Onion 2 pro SSID Issues after flashing custom image

    @Antony you an always use / to search inside make menuconfig, the warp core option is inside Onion->WiFi

    An easy way to reset your configuration is follow these steps:

    rm .config
    ln -s .config.O2 .config

    This resets back to the standard Omega2 configuration.

    posted in Projects

Looks like your connection to Community was lost, please wait while we try to reconnect.