This is a rewrite of the old molecube program as a daemon with simpler API without having to deal with HTTP/CGI protocols. All of the external communication will be done through a binary protocol on top of zmq. This way, the web frontend does not have to be on the same machine anymore and the frontend can also control multiple backend at the same time, all talking the same zmq protocol.
-
run_seq[version: 4bytes][len_ns: 8bytes][ttl_mask: 4bytes][bytecode: n](version 1 and 2)[len_ns: 8bytes][ttl_banks: 4bytes][ttl_mask: 4bytes x ttl_banks][bytecode: n](version 3)The version number and the code are passed in as two different ZMQ messages. This will be how the experiment talks to the backend. Supported versions are
1,2and3.The second message starts with the length of the sequence in nanoseconds (
len_ns) followed by the TTL mask. Only the TTL channels set in the mask will be controlled by the sequence. For version 1 and 2, there's only one TTL bank and the mask is a single 32bit number. For version 3, the mask starts with the number of TTL banks (ttl_banks,1to8) followed by one 32bit mask for each bank. The rest of the message is the bytecode.Return the 16 bytes sequence ID (an 8 bytes sequence number followed by an 8 bytes server ID) that can be waited/operated on by
wait_seqandcancel_seq. The server ID changes when the server restarts so that sequence ID's from before the restart are not accepted. The ID will be followed by the current low and high TTL override masks, each withttl_banks32bit numbers (ttl_banksis1for version 1 and 2), i.e.[ttl_lo_mask: 4bytes x ttl_banks][ttl_hi_mask: 4bytes x ttl_banks]. The rest of the reply is the list of the current DDS overrides in the same format as the reply ofget_override_dds, i.e.[[id: 1byte][val: 4bytes]] x n(seeoverride_ddsfor the format ofid). Only the overridden DDS parameters are included.The reply will be sent right away once the sequence is queued without waiting for the sequence to start or finish. Use
wait_seqto wait for the sequence.If the request is invalid,
[1: 1byte]is returned instead. -
run_cmdlist[version: 4bytes][len_ns: 8bytes][ttl_mask: 4bytes][cmd_list: n](version 1 and 2)[len_ns: 8bytes][ttl_banks: 4bytes][ttl_mask: 4bytes x ttl_banks][cmd_list: n](version 3)This is similar to
run_seqbut uses an uncompressed and simpler format which supports all operations. The arguments have the same format asrun_seqwith the bytecode replaced by the command list.The reply is the 16 bytes sequence ID followed by two bytes
[has_ttl_ovr: 1byte][has_dds_ovr: 1byte]indicating if there's any TTL and DDS overrides instead of returning the full info for the overridden channels. If the request is invalid,[1: 1byte]is returned instead. -
run_dma_seq[version: 4bytes][ttl_banks: 4bytes][ttl_mask: 4bytes x ttl_banks][dma_code: n]Run a sequence of DMA instructions that has already been compiled by the client. The version number and the code are passed in as two different ZMQ messages similar to
run_seq. The version is the version of the DMA instruction format. Only version0is currently supported.The second message starts with the TTL mask in the same format as version 3 of
run_seq/run_cmdlist, i.e. the number of TTL banks (ttl_banks,1to8) followed by one 32bit mask for each bank. Only the TTL channels set in the mask will be controlled by the sequence. Unlikerun_seq/run_cmdlist, there's no sequence length (len_ns).The rest of the message (
dma_code) is the DMA instructions, which are sent to the hardware as is. The length must be a non-zero multiple of 2 bytes. The server pads the end of the sequence with wait instructions to fill the last DMA block (128 bytes) and the sequence finishes after all the instructions are executed. The client is responsible for the timing of the instructions, e.g. the time each DDS instruction takes is reported byget_dds_inst_timing.The overridden TTL channels and DDS parameters are not changed by the sequence.
The reply is the same as
run_seqand the returned ID can be used withwait_seqandcancel_seq. If the request is invalid or if the DMA mode is not supported or not enabled on the server,[1: 1byte]is returned instead. -
wait_seq[id: 16bytes][state: 1byte]Wait for a sequence to reach a specific
state. Allowed values and their meanings for thestateare,-
1for flushedi.e. all commands sent to FPGA for execution.
-
2for finishedi.e. all commands has finished execution.
Return 1 byte (
0for success,1for cancellation) in the first message.If the wait is for the sequence finish, a second 4 bytes message is returned for the finish status flags. The flag can be
0signalling success or can be a or of one ore more of the following values.1: Underflow2: Trigger timedout
If a sequence is already cancelled before the request is recieved,
0could be returned. -
-
cancel_seq[id: 16bytes (optional)]Cancel one (or all) sequences. Return 1 bytes.
1if no sequence are cancelled.0if at least one sequence may be cancelled (though the sequence may not response if it is already started). -
state_idNo argument, return an incrementing 64bit ID followed by a 64bit process ID. The first bit of the id indicates if there's a sequence running, i.e. values are constantly changing and the rest 63 bits is the number of changes. requested after startup.
The caller can use this to avoid polling for update too frequently.
-
override_ttl[low mask: 4bytes][high mask: 4bytes][normal mask: 4bytes][bank: 4bytes (optional)]The three masks specify the changes to the high and low override masks to be made. The new high and low masks will be returned. If bank number is missing, it is assumed to be 0.
[0: 4bytes][0: 4bytes][0: 4bytes]is an no-op and can be used to get the current masks. -
set_ttl[low mask: 4bytes][high mask: 4bytes][bank: 4bytes (optional)]The two masks specify the channels to be turned on or off. This should have the same effect as running a sequence to turn a channel on/off. The new values will be returned including the override. If bank number is missing, it is assumed to be 0.
[0: 4bytes][0: 4bytes]is an no-op and can be used to get the current values.
-
override_dds[[[id: 1byte][val: 4bytes]] x n]where the 1 byte
idis[chn_num: 6bits][chn_type: 2bits]and a override value of0xffffffffmeans the override is disabled. Allowedchn_typevalues are:0: for DDS frequency1: for DDS amplitude2: for DDS phase
Return
0on success.1on error. -
get_override_ddsNo arguments. Return the list of overrides specified in the same format as the argument of
override_dds. -
set_dds[[[id: 1byte][val: 4bytes]] x n]Same as
override_dds. But set the current value without enabling override. Return0on success.1on error. -
get_ddsSee
get_override_ddsexcept that values for all enabled DDS's are returned. An optional list of 1 byte channel id (seeoverride_ddsfor format) can be included as argument for filtering. -
reset_dds[chn_num: 1byte]Reset the DDS. Returns
[0: 1byte].
TODO
-
set_clock[clock: 1byte]Return
[0: 1byte]. -
get_clockNo argument. Return
[clock: 1byte]
-
get_startupNo argument. Return the startup cmdlist in text format (NUL terminated).
-
set_startup[text form cmdlist: n bytes NUL terminate]Set the startup cmdlist. The sequence will be parsed immediately. If parsing succeeded, return
[0: 1 byte], otherwise, return a non zero error code as[errno: 1 byte]optionally followed by a serialization of theSyntaxErrorobject in the format:[message: n bytes NUL terminate] [line: n bytes NUL terminate] [lineno: 4bytes] [colnum: 4bytes] [colstart: 4bytes] [colend: 4bytes]The error code (
errno) currently will always be1but may be changed to include other values later. The serialized object following a1will always be aSyntaxError. Other error code added later might have other message following them. -
set_ttl_names[[chn: 1byte][name: n byte NUL terminate] x n]Return
[0: 1byte]if succeeded,[1: 1 byte]on error. -
get_ttl_namesReturn all TTL names in the same format as
set_ttl_names -
set_dds_namesSimilar to
set_ttl_names. Use the DDS instead of TTL channel number. -
get_ttl_namesSimilar to
get_ttl_names. Use the DDS instead of TTL channel number. -
name_idNo argument and similar to
state_id, return an incrementing 64bit ID followed by a 64bit process ID.The caller can use this to avoid polling for name.