Hello, I am a new nim user (forgive me if this post lacks info). Currently I am 
trying to create a socket connection and send a custom modbus packet. I am able 
to do this in C with <https://linux.die.net/man/2/sendto> and build my own 
packet as a char array and send it. Using the nim documentation, I wrote the 
following code:
    
    
    let
        ip = ""
        port = Port(502)
    
    
    var
        socket: Socket = newSocket()
    
    socket.connect(ip, port)
    
    #Create packet to write coil
    var packet: array[12, int] = [0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x01, 
0x05, 0x00, 0x00, 0xFF, 0x00];
    
    var dataPtr: ptr array = packet.addr
    
    
    socket.sendTo(ip, port, dataPtr, sizeof(packet), AF_INET, 0'i32)
    
    
    
    Run

With this I get the error "TCP not supported". Anyone have any tips? Is there a 
modbus library for nim that anyone can provide documentation for?

Thank you for any info!

Reply via email to