Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Bluetooth device

ChrisDe
2018-12-08
2018-12-13
  • ChrisDe - 2018-12-08

    Hi Guy's,

    i need some help...
    since several day i'd try to read the inputs from a bluetooth(wiimote)/usb(Xbox controller) device but without access...
    both devices are not connected at the same time.

    i used "joystick" to assign the devices

    what i've tried frist:
    i used the "SysFileAsync" -lib and an example from Viacheslav Mezentsev(Thanks!) to read out "dev/input/js0", i got some values but, these are crap and doesn't match with "hexdump".

    then i've tried to use the "SerialCommVisu" example from the store, but without access too.
    i didn't recive any input...

    //set the special parameters for the port
    // depending on the Port and the bandwidth the values should be adapted
    IF xTwoLines THEN
       FirstSerialLine(
          slMode:= SL_READ, //reading port 
          udiPort:= 1, //Port number
          udiBaudrate:= 11500, //bandwidth
          paParity:= COM.PARITY.EVEN, //the parity is optional
          sbStopBits:= COM.STOPBIT.ONESTOPBIT,
          udiByteSize := 8); //the stopbits are optional );
    (*   SecondSerialLine(
          slMode:= SL_WRITE,  //writing port
          udiPort:= 2, 
          udiBaudrate:=11500,
          paParity:= COM.PARITY.EVEN,
          sbStopBits:= COM.STOPBIT.ONESTOPBIT,
          udiByteSize := 8);*)
    ELSE
       (*ThirdSerialLine(
          slMode:= SL_READWRITE, 
          udiPort:= 6, 
          udiBaudrate:= 9600,
          paParity:= COM.PARITY.EVEN,
          sbStopBits:= COM.STOPBIT.ONESTOPBIT,
          udiByteSize := 8)*);
    END_IF
    

    here my "CODESYScontrol_user.cfg" config:

    Zitat:
    [SysCom]
    ;Linux.Devicefile=/dev/ttyS
    Linux.Devicefile=/dev/input/js0 //<-- joystick assignment for the Xb contoller or the Wiimote
    Linux.Devicefile=/dev/ttyAMA0 // <-- the wiimote is assigned to this device

    maybe someone has experience with this kind of application and give me an advice or push me on the right track.

    in the case of the implementation of BT devices via onboard BT controller of the Pi, Edwin can give some advices :3
    https://forum.codesys.com/viewtopic.php?t=8361

    thanks for your help! :>

    BG/Mfg,

    Christoph

     
  • Ingo

    Ingo - 2018-12-08

    Hi Chris!

    Sounds like a cool project!
    I think the way to go is to use the library CmpCharDevice to access the event interface directly.

    This bypasses all buffers and gives you a similar access as you achieve with the system calls open, read, write, close and ioctl directly.

    It would be great if you share your results after you got s.th. working. Preferably on https://forge.codesys.com which is still in a beta phase, to which you are heartly invited.

    BR,
    Ingo

    Gesendet von meinem LG-H870 mit Tapatalk

     
  • ChrisDe - 2018-12-10

    Hi Ingo,

    thank you for your response!
    i will try it out the next days... and for sure i will share the project and my experiences .

     
  • eschwellinger

    eschwellinger - 2018-12-13

    Hi,
    for the com port settings you need to add in

    /etc/CODESYSControl_User.cfg

    [SysCom]
    Linux.Devicefile=/dev/ttyAMA

    if you need to use more and different serial coms you need to do this in UDEV rules (under Linux)
    or even ( not nice) with symbolic links for exmaple /dev/ttyS-> /dev/ttyAMA1 then ttyAMA0 is Com1 and ttyAMA1 is Com2

    According the CmpChardevice... to read for exmaple/dev/input/js0 see attached example.

    BR
    Edwin

    RaspberryPI_CharDeviceSnippet.project [153.96 KiB]

     

Log in to post a comment.