How to rig this piston-like mechanical setup?

Looks like part of an eccentric rig, I did one for my traction engine, there is a video of the mechanics in the thread:

bandages is right it is best to work it out yourself as you will learn more in your attempts. I learned a lot from my trials and errors and was really proud of myself when I finally got it to work!

A spoiler:
«stretch to» «copy location» and «IK (with single chain lengths)»

If you are really stuck here is a simplified version like your example:
Bones.blend (749.3 KB)
Note: you have to pose the top black bone slowly if not you can get IK solving errors. Also the piston will offset slightly due to the angle of the yellow bone, you can correct it animating the original length of the stretch bone.