Giter Site home page Giter Site logo

Van communication about cdcemu HOT 4 OPEN

kuba2k2 avatar kuba2k2 commented on August 15, 2024
Van communication

from cdcemu.

Comments (4)

kuba2k2 avatar kuba2k2 commented on August 15, 2024

Hi, it probably is possible, but I don't own any other cars so I'm not able to do this myself.

from cdcemu.

Klewciax avatar Klewciax commented on August 15, 2024

Ok, I have Peugeot 206 so if you want to add this functionality I can check and debug your software :) Additionally, I found the VAN description on http://pinterpeti.hu/psavanbus/PSA-VAN.html

from cdcemu.

morcibacsi avatar morcibacsi commented on August 15, 2024

To support the VAN bus an additional IC is required (TSS463) you can see a few sample schematics in my repo: https://github.com/morcibacsi/arduino_tss463_van

To emulate a CDC on the VAN bus, alI you need is a few lines of code. Here is an Arduino sample code, which uses my TSS463 library (not the latest version, but I am happy to help converting it to the up to date version if needed):

#include "VanMessageSender.h"
const int VAN_PIN = 7;

AbstractVanMessageSender *VANInterface;
unsigned long currentTime = millis();
unsigned long previousCdcTime = millis();
volatile uint8_t seconds = 0;
volatile uint8_t headerByte = 0x80;


void IncrementHeader()
{
    if (headerByte == 0x87)
    {
        headerByte = 0x80;
    }
    else
    {
        headerByte++;
    }
}

void IncrementSeconds()
{
    seconds++;
    if (seconds == 60)
    {
        seconds = 0;
    }
}

uint8_t DecToBcd(uint8_t input)
{
    return( (input/10*16) + (input%10) );
}

void AnswerToCDC()
{
    uint8_t status = 0xC3; //playing
    uint8_t cartridge = 0x16;
    uint8_t minutes = 0x01;
    uint8_t trackNo = 0x17;
    uint8_t cdNo = 0x02;
    uint8_t trackCount = 0x21;
   
    uint8_t packet[12] = { headerByte, 0x00, status, cartridge, minutes, DecToBcd(seconds), trackNo, cdNo, trackCount, 0x3f, 0x01, headerByte };
    VANInterface->set_channel_for_immediate_reply_message(0, 0x4EC, packet, 12);
}

void setup(){
    VANInterface = new VanMessageSender(VAN_PIN);
    VANInterface->begin();
}

void loop() {
    currentTime = millis();
    if (currentTime - previousCdcTime >= 1000)
    {
        previousCdcTime = currentTime;

        IncrementSeconds();
        IncrementHeader();

        AnswerToCDC();
    }
}

from cdcemu.

kuba2k2 avatar kuba2k2 commented on August 15, 2024

I see, thanks for the answer. This is obviously possible, but would require a major code refactor, as well as a notable hardware change. CDCEmu depends highly on the CDC commands sent by the radio/display, so that would need to be implemented as well.

I'm planning to build a new version anyway, based on ESP32 with built-in Bluetooth, better quality, etc, and single-boarded. Thus, the code would need to be rewritten as well. I'm planning to do a more universal and abstracted architecture of "sources" (Bluetooth, AUX, etc) and the output protocols (CAN RD4, VAN for example, and since I have a 2006 Golf as well it could help to emulate CDC there).

To be honest, I do not have any ETA for that. There's just too much work around other projects, college and stuff. For now CDCEmu "works" so it's sadly pushed to a lower priority. I hope you can understand that.

from cdcemu.

Related Issues (1)

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.