Send Message Using Simply CAN with PYTHON

Hello,

I have an other question about the use of the simplycan python : How can I use correctly the sending message function ?

As I understang, the sending line must use the TxMsg :

TxMsg = Message(0x100, [1,2,3,4,5,6,7,8])

==> how can I modify this message if for example I want to send this message :

0x482 80 11 00 00 04 0A 5A 5A

And how can I send the message ? Do I only specify it in this bloc (the line send_message?):

 while True:
        if time.time() - lastSent > 1.0:  # one message every second
            lastSent = time.time()
            send_message(TxMsg)
            print("CAN Status:", format_status(simply.can_status()[0]))
        if not receive_messages():
            time.sleep(0.01)

Thank you for all.

It looks like the TxMsg is building a CANid and then 8 bytes of data. You should be able to update the data as you chose.

The while loop is cyclically sending the message and then checking for a received message. The loop is not necessary and using just send_message(TxMsg) should send the message. keep in mind the python script includes supporting functions and setup.
You can find additional details in the …\simplyCAN_WIN_1_1_0\doc\html directory

Hello, yes I succeed in sending messages, but I have one question, is it normal while I print the send message to read 0000 as time ? as :



    lastSent = 0
    TxMsg = Message(0x100, [1,2,3,4,5,6,7,8])
    
    TxMsg00 = Message(0x00, [0x01, 0x02])   
    TxMsg80 = Message(time, 0x80)                          

    print("Run application...")
    while True:
        if time.time() - lastSent > 0.1:  
            lastSent = time.time()
            send_message(TxMsg80)
            print(TxMsg80)
            time.sleep(0.001)

In the command window, I read all can messages but the TxMsg80 doesn’t have the same kind of time format. For example, the send message have 000000 as time, normal ? :

0000211046 0x382  00 00 00 00 00 00 02
0000211047 0x482  80 11 00 00 08 02 FF FF
0000211047 0x2AB  AC 0D AC 0D 00 00 01 01
0000211048 0x702  05
0000000000 0x80
0000211145 0x182  03 00 01 20 84 08 02 09
0000211146 0x282  00 00 00 00 00 00 00 00
0000211146 0x382  00 00 00 00 00 00 02

thank you.

I am not very familiar with this program or what you are trying to do here. Looking just at this snip it I would expect the variable time to just have 0’s. I would verify there is a value for time.