Engine Comp doesn't show/update TOP output for TCP DAT -> Script TOP toy example?

Hello there,

I have a Engine Comp which contains a tcp dat which is copying raw bytes to a script top. When I use these in a container on their own I can send the script top’s texture to an out and it contains the data as pixels that I’m sending from my server. The issue comes when I export that container to a .tox file and try to put it into an engine comp. I’ve included a couple of other OP outputs to ensure that the issue is specific to the script top. Has anyone run into this issue before? How would you advise? Thanks for all your help!

container_tcp_script.tox (2.9 KB)

Note this is a continuation of another thread left here Receiving a jpg from remote machine - #6 by raganmd

@humbletang do you have example that has your sending mechanic as well? With only the receiver I’m only seeing half the story :grimacing:

I’d guess based on the previous post you’re sending a jpg as a bytes, then wanting to decode on the other side. I don’t want to make too many assumptions though :slight_smile:

Good point, sorry for leaving out a big bit like that. I’ll include the code I’m using, but I think I’m going to use just raw bytes, not jpg data so its nothing too specific at this point. I wrote in rust but all that’s happening is I create a server, bind it to the ethernet connection I have between computers and then send 512 bytes of random numbers when a connection to TD is made.

use rand::prelude::*;
use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
use std::thread;
use std::time::{Duration, SystemTime};

fn main() {
    let listener = TcpListener::bind("10.42.0.1:8000").expect("no bind");
    // this is when a connection happens, but perhaps push into a thread and continue to send it data instead of just closing
    for stream in listener.incoming() {
        println!("got connection ");
        let stream = stream.unwrap();
        handle_connection(stream);
    }
}
fn handle_connection(mut s: TcpStream) {
    // empty array
    loop {
        let mut data = [0u8; 512];
        println!("{}",data.len());
        let mut thread = rand::thread_rng();
        thread.fill_bytes(&mut data);
        // use gen from thread to make data
        s.write(&data).unwrap();
        s.flush().unwrap();
        thread::sleep(Duration::from_secs(1));
    }
}

Have you tried force cooking the Script TOP after you have copied your bytes to it? I had a similar issue in a project where downstream TOPs from the Script TOP did not update after a copynumpyarray to the Script TOP, and I used this to solve it.

@nettoyeur Hello there! I just tried to do a force cook and still no good. I made a little video showing the difference in behavior between the container running outside the Engine Comp vs Within it in case that helps in place of a fully transferable reproducible example.

@humbletang I meant doing a forced cook of the Script TOP, in your video you are force cooking the Null TOP. So in you tcp-ip1_callbacks DAT, at line 37, insert this line:

op("script1").cook(force=True)

@nettoyeur That did it! Thanks for the fix. I haven’t really dug into the theory behind cooking, is there a simple explanation for what force cooking did in this instance?

TLDR; it gives any TOP connected to your output a reason to cook.

Detailed explanation:
https://docs.derivative.ca/Cook

But I feel copyNumpyArray should do this automatically, I’ll create an RFE for Derivative.

Thanks for the quick summary and the link to where I can learn more. This has been a huge help and now I have a whole new avenue to explore for my active project. Thanks @nettoyeur @raganmd for helping out on this issue.

3 Likes